Exit Codes: Difference between revisions
No edit summary |
No edit summary |
||
| Line 87: | Line 87: | ||
For example, the exit code 32512 has an exit code of 127 (command not found). | For example, the exit code 32512 has an exit code of 127 (command not found). | ||
== Systemd exit codes == | ==Systemd exit codes== | ||
See the systemd documentation: https://www.freedesktop.org/software/systemd/man/systemd.exec.html | See the systemd documentation: https://www.freedesktop.org/software/systemd/man/systemd.exec.html | ||
{| class="wikitable" | {| class="wikitable" | ||
| Line 128: | Line 128: | ||
|208 | |208 | ||
|<code>EXIT_STDIN</code> | |<code>EXIT_STDIN</code> | ||
|Failed to set up standard input. Issue with <code>StandardInput=</code> | |Failed to set up standard input. Issue with <code>StandardInput=</code> | ||
|- | |- | ||
|209 | |209 | ||
| Line 136: | Line 136: | ||
|210 | |210 | ||
|<code>EXIT_CHROOT</code> | |<code>EXIT_CHROOT</code> | ||
|Failed to change root directory (chroot(2)). Issue with <code>RootDirectory=</code>/<code>RootImage=</code> | |Failed to change root directory (chroot(2)). Issue with <code>RootDirectory=</code>/<code>RootImage=</code> | ||
|- | |- | ||
|211 | |211 | ||
|<code>EXIT_IOPRIO</code> | |<code>EXIT_IOPRIO</code> | ||
|Failed to set up IO scheduling priority. Issue with <code>IOSchedulingClass=</code>/<code>IOSchedulingPriority=</code> | |Failed to set up IO scheduling priority. Issue with <code>IOSchedulingClass=</code>/<code>IOSchedulingPriority=</code> | ||
|- | |- | ||
|212 | |212 | ||
| Line 152: | Line 152: | ||
|214 | |214 | ||
|<code>EXIT_SETSCHEDULER</code> | |<code>EXIT_SETSCHEDULER</code> | ||
|Failed to set up CPU scheduling. Issue with <code>CPUSchedulingPolicy=</code>/<code>CPUSchedulingPriority=</code> | |Failed to set up CPU scheduling. Issue with <code>CPUSchedulingPolicy=</code>/<code>CPUSchedulingPriority=</code> | ||
|- | |- | ||
|215 | |215 | ||
| Line 160: | Line 160: | ||
|216 | |216 | ||
|<code>EXIT_GROUP</code> | |<code>EXIT_GROUP</code> | ||
|Failed to determine or change group credentials. Issue with <code>Group=</code>/<code>SupplementaryGroups=</code> | |Failed to determine or change group credentials. Issue with <code>Group=</code>/<code>SupplementaryGroups=</code> | ||
|- | |- | ||
|217 | |217 | ||
|<code>EXIT_USER</code> | |<code>EXIT_USER</code> | ||
|Failed to determine or change user credentials, or to set up user namespacing. Issue with <code>User=</code>/<code>PrivateUsers=</code> | |Failed to determine or change user credentials, or to set up user namespacing. Issue with <code>User=</code>/<code>PrivateUsers=</code> | ||
|- | |- | ||
|218 | |218 | ||
|<code>EXIT_CAPABILITIES</code> | |<code>EXIT_CAPABILITIES</code> | ||
|Failed to drop capabilities, or apply ambient capabilities. Issue with <code>CapabilityBoundingSet=</code>/<code>AmbientCapabilities=</code> | |Failed to drop capabilities, or apply ambient capabilities. Issue with <code>CapabilityBoundingSet=</code>/<code>AmbientCapabilities=</code> | ||
|- | |- | ||
|219 | |219 | ||
| Line 184: | Line 184: | ||
|222 | |222 | ||
|<code>EXIT_STDERR</code> | |<code>EXIT_STDERR</code> | ||
|Failed to set up standard error output. Issue with <code>StandardError=</code> | |Failed to set up standard error output. Issue with <code>StandardError=</code> | ||
|- | |- | ||
|224 | |224 | ||
|<code>EXIT_PAM</code> | |<code>EXIT_PAM</code> | ||
|Failed to set up PAM session. Issue with <code>PAMName=</code> | |Failed to set up PAM session. Issue with <code>PAMName=</code> | ||
|- | |- | ||
|225 | |225 | ||
| Line 200: | Line 200: | ||
|227 | |227 | ||
|<code>EXIT_NO_NEW_PRIVILEGES</code> | |<code>EXIT_NO_NEW_PRIVILEGES</code> | ||
|Failed to disable new privileges. Issue with <code>NoNewPrivileges=yes</code> | |Failed to disable new privileges. Issue with <code>NoNewPrivileges=yes</code> | ||
|- | |- | ||
|228 | |228 | ||
| Line 208: | Line 208: | ||
|229 | |229 | ||
|<code>EXIT_SELINUX_CONTEXT</code> | |<code>EXIT_SELINUX_CONTEXT</code> | ||
|Determining or changing SELinux context failed. Issue with <code>SELinuxContext=</code> | |Determining or changing SELinux context failed. Issue with <code>SELinuxContext=</code> | ||
|- | |- | ||
|230 | |230 | ||
|<code>EXIT_PERSONALITY</code> | |<code>EXIT_PERSONALITY</code> | ||
|Failed to set up an execution domain (personality). Issue with <code>Personality=</code> | |Failed to set up an execution domain (personality). Issue with <code>Personality=</code> | ||
|- | |- | ||
|231 | |231 | ||
| Line 256: | Line 256: | ||
|242 | |242 | ||
|<code>EXIT_NUMA_POLICY</code> | |<code>EXIT_NUMA_POLICY</code> | ||
|Failed to set up unit's NUMA memory policy. Issue with <code>NUMAPolicy=</code> and <code>NUMAMask=</code> | |Failed to set up unit's NUMA memory policy. Issue with <code>NUMAPolicy=</code> and <code>NUMAMask=</code> | ||
|- | |- | ||
|243 | |243 | ||
|<code>EXIT_CREDENTIALS</code> | |<code>EXIT_CREDENTIALS</code> | ||
|Failed to set up unit's credentials. Issue with <code>LoadCredential=</code> and <code>SetCredential=</code> | |Failed to set up unit's credentials. Issue with <code>LoadCredential=</code> and <code>SetCredential=</code> | ||
|} | |||
== '''BSD exit codes''' == | |||
{| class="wikitable" | |||
!Exit Code | |||
!Symbolic Name | |||
!Description | |||
|- | |||
|64 | |||
|<code>EX_USAGE</code> | |||
|Command line usage error | |||
|- | |||
|65 | |||
|<code>EX_DATAERR</code> | |||
|Data format error | |||
|- | |||
|66 | |||
|<code>EX_NOINPUT</code> | |||
|Cannot open input | |||
|- | |||
|67 | |||
|<code>EX_NOUSER</code> | |||
|Addressee unknown | |||
|- | |||
|68 | |||
|<code>EX_NOHOST</code> | |||
|Host name unknown | |||
|- | |||
|69 | |||
|<code>EX_UNAVAILABLE</code> | |||
|Service unavailable | |||
|- | |||
|70 | |||
|<code>EX_SOFTWARE</code> | |||
|internal software error | |||
|- | |||
|71 | |||
|<code>EX_OSERR</code> | |||
|System error (e.g., can't fork) | |||
|- | |||
|72 | |||
|<code>EX_OSFILE</code> | |||
|Critical OS file missing | |||
|- | |||
|73 | |||
|<code>EX_CANTCREAT</code> | |||
|Can't create (user) output file | |||
|- | |||
|74 | |||
|<code>EX_IOERR</code> | |||
|Input/output error | |||
|- | |||
|75 | |||
|<code>EX_TEMPFAIL</code> | |||
|Temporary failure; user is invited to retry | |||
|- | |||
|76 | |||
|<code>EX_PROTOCOL</code> | |||
|Remote error in protocol | |||
|- | |||
|77 | |||
|<code>EX_NOPERM</code> | |||
|Permission denied | |||
|- | |||
|78 | |||
|<code>EX_CONFIG</code> | |||
|Configuration error | |||
|} | |} | ||
Revision as of 20:38, 23 November 2021
Here are some common exit codes that may be returned by a program or script.
| Exit Code | Description |
|---|---|
| 0 | Successful Termination |
| 1 | General Error, typical catch-all value |
| 2 | Misuse of shell builtins, keywords, or functions |
| 6 | No such device or address. Eg. curl on an invalid host. |
| 64-78 | BSD exit codes. See section below. |
| 124 | Command timed out (coreutils/timeout) |
| 125 | Command failure (coreutils/timeout) |
| 126 | Command found, but cannot be executed |
| 127 | Command not found. Possible path or typo issue. |
| 128 | Invalid argument to exit. Eg. exit 1.1 would result in 128.
|
| 128+n | Fatal error signal n, where n is the signal number as defined in: |
| 130 | Program Interrupted (SIGINT, 128+2), such as termination from Ctrl-C |
| 134 | Program Abort (SIGABRT, 128+6) |
| 136 | Erroneous Arithmetic Operation (SIGFPE, 128+8), such as division by zero |
| 137 | Killed. (SIGKILL, 128+9) |
| 139 | Segmentation Fault (SIGSEGV, 11) |
| 160+n | The largest signal value is 31. As a result, all values after 128+31 can be interpreted as negative return codes by treating the value as a 1 byte integer.
For example, 255 = -1, 254 = -2, 240 = -16, 225 = -31, and so forth A simple way to 'convert' it is to just subtract the value from 256. |
| 200-243 | Are you working with systemd? See section below. |
| 255 | Maximum exit code value. Obtained when the program calls exit -1.
|
| 256+ | All higher exit codes should be reduced down to the 0-255 range. More information below. You typically either modulo the code by 256 or take the high 8-bit values.
Eg. Code |
Parsing high exit code values
At least on Linux (and whatever is reported by Slurm), the exit code that's stored is an 2 byte value which can be parsed as:
| Bits | Description |
|---|---|
| high 8 bits | The actual exit code |
| 7 bit | if a core dump was produced |
| lower 7 bits | signal number that killed the process |
For example, the exit code 32512 has an exit code of 127 (command not found).
Systemd exit codes
See the systemd documentation: https://www.freedesktop.org/software/systemd/man/systemd.exec.html
| Exit Code | Symbolic Name | Description |
|---|---|---|
| 200 | EXIT_CHDIR
|
Changing to the requested working directory failed. Issue with WorkingDirectory=
|
| 201 | EXIT_NICE
|
Failed to set up process scheduling priority (nice level). Issue with Nice=
|
| 202 | EXIT_FDS
|
Failed to close unwanted file descriptors, or to adjust passed file descriptors. |
| 203 | EXIT_EXEC
|
The actual process execution failed (specifically, the execve(2) system call). Most likely this is caused by a missing or non-accessible executable file. |
| 204 | EXIT_MEMORY
|
Failed to perform an action due to memory shortage. |
| 205 | EXIT_LIMITS
|
Failed to adjust resource limits. Issue with LimitCPU= and related settings
|
| 206 | EXIT_OOM_ADJUST
|
Failed to adjust the OOM setting. Issue with OOMScoreAdjust=
|
| 207 | EXIT_SIGNAL_MASK
|
Failed to set process signal mask. |
| 208 | EXIT_STDIN
|
Failed to set up standard input. Issue with StandardInput=
|
| 209 | EXIT_STDOUT
|
Failed to set up standard output. Issue with StandardOutput=
|
| 210 | EXIT_CHROOT
|
Failed to change root directory (chroot(2)). Issue with RootDirectory=/RootImage=
|
| 211 | EXIT_IOPRIO
|
Failed to set up IO scheduling priority. Issue with IOSchedulingClass=/IOSchedulingPriority=
|
| 212 | EXIT_TIMERSLACK
|
Failed to set up timer slack. Issue with TimerSlackNSec=
|
| 213 | EXIT_SECUREBITS
|
Failed to set process secure bits. Issue with SecureBits=
|
| 214 | EXIT_SETSCHEDULER
|
Failed to set up CPU scheduling. Issue with CPUSchedulingPolicy=/CPUSchedulingPriority=
|
| 215 | EXIT_CPUAFFINITY
|
Failed to set up CPU affinity. Issue with CPUAffinity=
|
| 216 | EXIT_GROUP
|
Failed to determine or change group credentials. Issue with Group=/SupplementaryGroups=
|
| 217 | EXIT_USER
|
Failed to determine or change user credentials, or to set up user namespacing. Issue with User=/PrivateUsers=
|
| 218 | EXIT_CAPABILITIES
|
Failed to drop capabilities, or apply ambient capabilities. Issue with CapabilityBoundingSet=/AmbientCapabilities=
|
| 219 | EXIT_CGROUP
|
Setting up the service control group failed. |
| 220 | EXIT_SETSID
|
Failed to create new process session. |
| 221 | EXIT_CONFIRM
|
Execution has been cancelled by the user. See the systemd.confirm_spawn= kernel command line setting on kernel-command-line(7) for details.
|
| 222 | EXIT_STDERR
|
Failed to set up standard error output. Issue with StandardError=
|
| 224 | EXIT_PAM
|
Failed to set up PAM session. Issue with PAMName=
|
| 225 | EXIT_NETWORK
|
Failed to set up network namespacing. Issue with PrivateNetwork=
|
| 226 | EXIT_NAMESPACE
|
Failed to set up mount, UTS, or IPC namespacing. See ReadOnlyPaths=, ProtectHostname=, PrivateIPC=, and related settings.
|
| 227 | EXIT_NO_NEW_PRIVILEGES
|
Failed to disable new privileges. Issue with NoNewPrivileges=yes
|
| 228 | EXIT_SECCOMP
|
Failed to apply system call filters. See SystemCallFilter= and related settings
|
| 229 | EXIT_SELINUX_CONTEXT
|
Determining or changing SELinux context failed. Issue with SELinuxContext=
|
| 230 | EXIT_PERSONALITY
|
Failed to set up an execution domain (personality). Issue with Personality=
|
| 231 | EXIT_APPARMOR_PROFILE
|
Failed to prepare changing AppArmor profile. Issue with AppArmorProfile=
|
| 232 | EXIT_ADDRESS_FAMILIES
|
Failed to restrict address families. Issue with RestrictAddressFamilies=
|
| 233 | EXIT_RUNTIME_DIRECTORY
|
Setting up runtime directory failed. See RuntimeDirectory= and related settings
|
| 235 | EXIT_CHOWN
|
Failed to adjust socket ownership. Used for socket units only. |
| 236 | EXIT_SMACK_PROCESS_LABEL
|
Failed to set SMACK label. Issue with SmackProcessLabel=
|
| 237 | EXIT_KEYRING
|
Failed to set up kernel keyring. |
| 238 | EXIT_STATE_DIRECTORY
|
Failed to set up unit's state directory. Issue with StateDirectory=
|
| 239 | EXIT_CACHE_DIRECTORY
|
Failed to set up unit's cache directory. Issue with CacheDirectory=
|
| 240 | EXIT_LOGS_DIRECTORY
|
Failed to set up unit's logging directory. Issue with LogsDirectory=
|
| 241 | EXIT_CONFIGURATION_DIRECTORY
|
Failed to set up unit's configuration directory. Issue with ConfigurationDirectory=
|
| 242 | EXIT_NUMA_POLICY
|
Failed to set up unit's NUMA memory policy. Issue with NUMAPolicy= and NUMAMask=
|
| 243 | EXIT_CREDENTIALS
|
Failed to set up unit's credentials. Issue with LoadCredential= and SetCredential=
|
BSD exit codes
| Exit Code | Symbolic Name | Description |
|---|---|---|
| 64 | EX_USAGE
|
Command line usage error |
| 65 | EX_DATAERR
|
Data format error |
| 66 | EX_NOINPUT
|
Cannot open input |
| 67 | EX_NOUSER
|
Addressee unknown |
| 68 | EX_NOHOST
|
Host name unknown |
| 69 | EX_UNAVAILABLE
|
Service unavailable |
| 70 | EX_SOFTWARE
|
internal software error |
| 71 | EX_OSERR
|
System error (e.g., can't fork) |
| 72 | EX_OSFILE
|
Critical OS file missing |
| 73 | EX_CANTCREAT
|
Can't create (user) output file |
| 74 | EX_IOERR
|
Input/output error |
| 75 | EX_TEMPFAIL
|
Temporary failure; user is invited to retry |
| 76 | EX_PROTOCOL
|
Remote error in protocol |
| 77 | EX_NOPERM
|
Permission denied |
| 78 | EX_CONFIG
|
Configuration error |
See Also
- https://tldp.org/LDP/abs/html/exitcodes.html
- Coreutils / Timeout: https://www.gnu.org/software/coreutils/manual/html_node/timeout-invocation.html