Are there any standard exit status codes in Linux?

后端 未结 10 1697
醉话见心
醉话见心 2020-11-22 06:46

A process is considered to have completed correctly in Linux if its exit status was 0.

I\'ve seen that segmentation faults often result in an exit status of 11, thou

10条回答
  •  悲哀的现实
    2020-11-22 07:13

    Programs return a 16 bit exit code. If the program was killed with a signal then the high order byte contains the signal used, otherwise the low order byte is the exit status returned by the programmer.

    How that exit code is assigned to the status variable $? is then up to the shell. Bash keeps the lower 7 bits of the status and then uses 128 + (signal nr) for indicating a signal.

    The only "standard" convention for programs is 0 for success, non-zero for error. Another convention used is to return errno on error.

提交回复
热议问题