Exit Codes
Exit codes are numbers that are returned by a program when it exits.
Understanding exit codes
Exit codes are used to determine whether a program completed successfully or encountered an issue. Depending on the operating system you're using (Linux, BSD, or Windows), you'll likely encounter different exit code conventions.
This page will try to cover most common exit codes to help you troubleshoot.
Common exit codes
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 the BSD 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 the systemd 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 |
High value exit codes (>256)
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 (200-243)
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 (64-78)
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
- errno - error numbers used in Linux (
errno -ls
)