int main()
{
...
return 0;
}
(http://cis2.oc.ctc.edu/oc_apps/Westlund/xbook/xbook.php?unit=04&proc=page&numb=1)
(https://devwhkang.gatsbyjs.io/posts/os-systemcall/)
$ ./a.out
$ echo $?
0
만약 main함수에서 return 1
을 한다면, echo $?
에서 1
이 출력된다.
https://stackoverflow.com/questions/5163144/what-are-the-special-dollar-sign-shell-variables
- $1, $2, $3, ... are the positional parameters.
- "$@" is an array-like construct of all positional parameters, {$1, $2, $3 ...}.
- "$*" is the IFS expansion of all positional parameters, $1 - $2 $3 ....
- $# is the number of positional parameters.
- $- current options set for the shell.
- $$ pid of the current shell (not subshell).
- $_ most recent parameter (or the abs path of the command to start the current shell immediately after startup).
- $IFS is the (input) field separator.
- $? is the most recent foreground pipeline exit status.
- $! is the PID of the most recent background command.
- $0 is the name of the shell or shell script.
linux에서 SUCEESS는 0
으로 정의한다.
(https://m.blog.naver.com/geartec82/220863754963)
https://android.googlesource.com/kernel/lk/+/dima/for-travis/include/errno.h
#define EPERM 1 /* Not super-user */ #define ENOENT 2 /* No such file or directory */ #define ESRCH 3 /* No such process */ #define EINTR 4 /* Interrupted system call */ #define EIO 5 /* I/O error */ #define ENXIO 6 /* No such device or address */ #define E2BIG 7 /* Arg list too long */ #define ENOEXEC 8 /* Exec format error */ #define EBADF 9 /* Bad file number */ #define ECHILD 10 /* No children */ #define EAGAIN 11 /* No more processes */ ...