0% found this document useful (0 votes)
31 views2 pages

Windows Standard Codes

This document provides a table summarizing common Linux/Unix exit codes and their meanings. It notes that exit codes 1-2, 126-165, and 255 have special predefined meanings and should be avoided for user-defined codes. The document proposes restricting user-defined exit codes to the range of 64-113 to avoid confusion and make scripts more straightforward to troubleshoot, as codes in this range do not have predefined shell meanings. Running non-bash shells may sometimes produce different exit code values than what the table shows for bash.

Uploaded by

abybaby85
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views2 pages

Windows Standard Codes

This document provides a table summarizing common Linux/Unix exit codes and their meanings. It notes that exit codes 1-2, 126-165, and 255 have special predefined meanings and should be avoided for user-defined codes. The document proposes restricting user-defined exit codes to the range of 64-113 to avoid confusion and make scripts more straightforward to troubleshoot, as codes in this range do not have predefined shell meanings. Running non-bash shells may sometimes produce different exit code values than what the table shows for bash.

Uploaded by

abybaby85
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Exit Meaning Example Comments

Code
Number
1 Catchall for general let "var1 = Miscellaneous errors, such
errors 1/0" as "divide by zero" and other
impermissible operations
2 Misuse of shell empty_functio Missing keyword or command,
builtins (according n() {} or permission problem
to Bash (and dif return code on a failed
documentation) binary file comparison).
126 Command invoked /dev/null Permission problem or
cannot execute command is not an executable
127 "command not illegal_comma Possible problem with $PATH or a
found" nd typo
128 Invalid argument exit 3.14159 exit takes only integer args in
to exit the range 0 - 255 (see first
footnote)
128+n Fatal error signal "n" kill -9 $PPID of $? returns 137 (128 + 9)
script
130 Script terminated by Ctl-C Control-C is fatal error signal 2,
Control-C (130 = 128 + 2, see above)
255* Exit status out of exit -1 exit takes only integer args in
range the range 0 - 255

According to the above table, exit codes 1 - 2, 126 - 165, and 255 have
special meanings, and should therefore be avoided for user-specified exit
parameters. Ending a script with exit 127 would certainly cause confusion
when troubleshooting (is the error code a "command not found" or a user-
defined one?). However, many scripts use an exit 1 as a general bailout-
upon-error. Since exit code 1 signifies so many possible errors, it is not
particularly useful in debugging.

There has been an attempt to systematize exit status numbers


(see /usr/include/sysexits.h), but this is intended for C and C++
programmers. A similar standard for scripting might be appropriate. The
author of this document proposes restricting user-defined exit codes to the
range 64 - 113 (in addition to 0, for success), to conform with the C/C++
standard. This would allot 50 valid codes, and make troubleshooting scripts
more straightforward. All user-defined exit codes in the accompanying
examples to this document conform to this standard, except where
overriding circumstances exist.
Issuing a $? from the command-line after a shell script exits gives results
consistent with the table above only from the Bash or sh prompt. Running
the C-shell or tcsh may give diferent values in some cases

You might also like