Exit Codes: Difference between revisions
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
Here are some common exit codes that may be returned by a program or script. | Here are some common exit codes that may be returned by a program or script. | ||
{| class="wikitable" | {| class="wikitable" | ||
! | !Exit Code | ||
!Description | !Description | ||
|- | |- | ||
| Line 15: | Line 15: | ||
|6 | |6 | ||
|No such device or address. Eg. curl on an invalid host. | |No such device or address. Eg. curl on an invalid host. | ||
|- | |||
|64-78 | |||
|BSD exit codes. See section below. | |||
|- | |- | ||
|124 | |124 | ||
| Line 55: | Line 58: | ||
A simple way to 'convert' it is to just subtract the value from 256. | 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 | |255 | ||
| Line 80: | Line 86: | ||
|} | |} | ||
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 == | |||
See the systemd documentation: https://www.freedesktop.org/software/systemd/man/systemd.exec.html | |||
{| class="wikitable" | |||
!Exit Code | |||
!Symbolic Name | |||
!Description | |||
|- | |||
|200 | |||
|<code>EXIT_CHDIR</code> | |||
|Changing to the requested working directory failed. Issue with <code>WorkingDirectory=</code> | |||
|- | |||
|201 | |||
|<code>EXIT_NICE</code> | |||
|Failed to set up process scheduling priority (nice level). Issue with <code>Nice=</code> | |||
|- | |||
|202 | |||
|<code>EXIT_FDS</code> | |||
|Failed to close unwanted file descriptors, or to adjust passed file descriptors. | |||
|- | |||
|203 | |||
|<code>EXIT_EXEC</code> | |||
|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 | |||
|<code>EXIT_MEMORY</code> | |||
|Failed to perform an action due to memory shortage. | |||
|- | |||
|205 | |||
|<code>EXIT_LIMITS</code> | |||
|Failed to adjust resource limits. Issue with <code>LimitCPU=</code> and related settings | |||
|- | |||
|206 | |||
|<code>EXIT_OOM_ADJUST</code> | |||
|Failed to adjust the OOM setting. Issue with <code>OOMScoreAdjust=</code> | |||
|- | |||
|207 | |||
|<code>EXIT_SIGNAL_MASK</code> | |||
|Failed to set process signal mask. | |||
|- | |||
|208 | |||
|<code>EXIT_STDIN</code> | |||
|Failed to set up standard input. Issue with <code>StandardInput=</code> | |||
|- | |||
|209 | |||
|<code>EXIT_STDOUT</code> | |||
|Failed to set up standard output. Issue with <code>StandardOutput=</code> | |||
|- | |||
|210 | |||
|<code>EXIT_CHROOT</code> | |||
|Failed to change root directory (chroot(2)). Issue with <code>RootDirectory=</code>/<code>RootImage=</code> | |||
|- | |||
|211 | |||
|<code>EXIT_IOPRIO</code> | |||
|Failed to set up IO scheduling priority. Issue with <code>IOSchedulingClass=</code>/<code>IOSchedulingPriority=</code> | |||
|- | |||
|212 | |||
|<code>EXIT_TIMERSLACK</code> | |||
|Failed to set up timer slack. Issue with <code>TimerSlackNSec=</code> | |||
|- | |||
|213 | |||
|<code>EXIT_SECUREBITS</code> | |||
|Failed to set process secure bits. Issue with <code>SecureBits=</code> | |||
|- | |||
|214 | |||
|<code>EXIT_SETSCHEDULER</code> | |||
|Failed to set up CPU scheduling. Issue with <code>CPUSchedulingPolicy=</code>/<code>CPUSchedulingPriority=</code> | |||
|- | |||
|215 | |||
|<code>EXIT_CPUAFFINITY</code> | |||
|Failed to set up CPU affinity. Issue with <code>CPUAffinity=</code> | |||
|- | |||
|216 | |||
|<code>EXIT_GROUP</code> | |||
|Failed to determine or change group credentials. Issue with <code>Group=</code>/<code>SupplementaryGroups=</code> | |||
|- | |||
|217 | |||
|<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> | |||
|- | |||
|218 | |||
|<code>EXIT_CAPABILITIES</code> | |||
|Failed to drop capabilities, or apply ambient capabilities. Issue with <code>CapabilityBoundingSet=</code>/<code>AmbientCapabilities=</code> | |||
|- | |||
|219 | |||
|<code>EXIT_CGROUP</code> | |||
|Setting up the service control group failed. | |||
|- | |||
|220 | |||
|<code>EXIT_SETSID</code> | |||
|Failed to create new process session. | |||
|- | |||
|221 | |||
|<code>EXIT_CONFIRM</code> | |||
|Execution has been cancelled by the user. See the <code>systemd.confirm_spawn=</code> kernel command line setting on kernel-command-line(7) for details. | |||
|- | |||
|222 | |||
|<code>EXIT_STDERR</code> | |||
|Failed to set up standard error output. Issue with <code>StandardError=</code> | |||
|- | |||
|224 | |||
|<code>EXIT_PAM</code> | |||
|Failed to set up PAM session. Issue with <code>PAMName=</code> | |||
|- | |||
|225 | |||
|<code>EXIT_NETWORK</code> | |||
|Failed to set up network namespacing. Issue with <code>PrivateNetwork=</code> | |||
|- | |||
|226 | |||
|<code>EXIT_NAMESPACE</code> | |||
|Failed to set up mount, UTS, or IPC namespacing. See <code>ReadOnlyPaths=</code>, <code>ProtectHostname=</code>, <code>PrivateIPC=</code>, and related settings. | |||
|- | |||
|227 | |||
|<code>EXIT_NO_NEW_PRIVILEGES</code> | |||
|Failed to disable new privileges. Issue with <code>NoNewPrivileges=yes</code> | |||
|- | |||
|228 | |||
|<code>EXIT_SECCOMP</code> | |||
|Failed to apply system call filters. See <code>SystemCallFilter=</code> and related settings | |||
|- | |||
|229 | |||
|<code>EXIT_SELINUX_CONTEXT</code> | |||
|Determining or changing SELinux context failed. Issue with <code>SELinuxContext=</code> | |||
|- | |||
|230 | |||
|<code>EXIT_PERSONALITY</code> | |||
|Failed to set up an execution domain (personality). Issue with <code>Personality=</code> | |||
|- | |||
|231 | |||
|<code>EXIT_APPARMOR_PROFILE</code> | |||
|Failed to prepare changing AppArmor profile. Issue with <code>AppArmorProfile=</code> | |||
|- | |||
|232 | |||
|<code>EXIT_ADDRESS_FAMILIES</code> | |||
|Failed to restrict address families. Issue with <code>RestrictAddressFamilies=</code> | |||
|- | |||
|233 | |||
|<code>EXIT_RUNTIME_DIRECTORY</code> | |||
|Setting up runtime directory failed. See <code>RuntimeDirectory=</code> and related settings | |||
|- | |||
|235 | |||
|<code>EXIT_CHOWN</code> | |||
|Failed to adjust socket ownership. Used for socket units only. | |||
|- | |||
|236 | |||
|<code>EXIT_SMACK_PROCESS_LABEL</code> | |||
|Failed to set SMACK label. Issue with <code>SmackProcessLabel=</code> | |||
|- | |||
|237 | |||
|<code>EXIT_KEYRING</code> | |||
|Failed to set up kernel keyring. | |||
|- | |||
|238 | |||
|<code>EXIT_STATE_DIRECTORY</code> | |||
|Failed to set up unit's state directory. Issue with <code>StateDirectory=</code> | |||
|- | |||
|239 | |||
|<code>EXIT_CACHE_DIRECTORY</code> | |||
|Failed to set up unit's cache directory. Issue with <code>CacheDirectory=</code> | |||
|- | |||
|240 | |||
|<code>EXIT_LOGS_DIRECTORY</code> | |||
|Failed to set up unit's logging directory. Issue with <code>LogsDirectory=</code> | |||
|- | |||
|241 | |||
|<code>EXIT_CONFIGURATION_DIRECTORY</code> | |||
|Failed to set up unit's configuration directory. Issue with <code>ConfigurationDirectory=</code> | |||
|- | |||
|242 | |||
|<code>EXIT_NUMA_POLICY</code> | |||
|Failed to set up unit's NUMA memory policy. Issue with <code>NUMAPolicy=</code> and <code>NUMAMask=</code> | |||
|- | |||
|243 | |||
|<code>EXIT_CREDENTIALS</code> | |||
|Failed to set up unit's credentials. Issue with <code>LoadCredential=</code> and <code>SetCredential=</code> | |||
|} | |||
==See Also== | ==See Also== | ||
Revision as of 20:37, 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=
|
See Also
- https://tldp.org/LDP/abs/html/exitcodes.html
- Coreutils / Timeout: https://www.gnu.org/software/coreutils/manual/html_node/timeout-invocation.html