Skip to content
shellhacks.dev

Exit Codes and Signals

What a process's exit status means: general errors, command not found, sysexits codes, and 128 plus a signal number such as 137 (SIGKILL, OOM) and 143 (SIGTERM).

Free · No sign-up · Your inputs stay in your browser

Reference

Exit codes and signals

CodeMeaningNotes
0Success
1General errorCatch-all for any failure; most programs use only 0 and 1.
2Misuse of a shell builtin / bad argumentsMany CLIs return 2 for invalid usage.
64EX_USAGECommand used incorrectly (sysexits.h).
65EX_DATAERRInput data was incorrect.
66EX_NOINPUTAn input file did not exist or was unreadable.
69EX_UNAVAILABLEA service is unavailable.
70EX_SOFTWAREInternal software error.
71EX_OSERROperating system error, e.g. cannot fork.
73EX_CANTCREATCannot create an output file.
74EX_IOERRInput/output error.
75EX_TEMPFAILTemporary failure; retrying may work. Mail servers queue and retry on it.
77EX_NOPERMPermission denied.
78EX_CONFIGConfiguration error.
125docker run failedThe Docker daemon could not run the container (bad flag, image problem).
126Command not executableFound but not executable: missing chmod +x, or a directory.
127Command not foundNot on PATH, or a script's #! interpreter does not exist (also shown for CRLF line endings).
128Invalid exit argumentexit was called with a value outside 0-255.
129SIGHUP (1)Terminal closed; daemons often use it to reload configuration.
130SIGINT (2)Ctrl+C.
131SIGQUIT (3)Ctrl+\; dumps core.
134SIGABRT (6)abort(), a failed assertion or a corrupted heap.
135SIGBUS (7)Bus error, misaligned memory access.
136SIGFPE (8)Arithmetic error such as integer division by zero.
137SIGKILL (9)Killed outright: kill -9, or the kernel OOM killer. In Kubernetes this is OOMKilled when the container exceeded its memory limit.
139SIGSEGV (11)Segmentation fault: invalid memory access, often a native extension.
141SIGPIPE (13)Wrote to a pipe whose reader exited, e.g. a command piped into head.
142SIGALRM (14)Timer expired.
143SIGTERM (15)Polite stop: docker stop, systemctl stop, a Kubernetes pod shutting down. Should be handled and exit cleanly.
152SIGXCPU (24)CPU time limit (ulimit -t) exceeded.
153SIGXFSZ (25)File size limit exceeded.
255Exit status out of rangeexit -1 wraps to 255; ssh returns 255 when the connection itself fails.

A process killed by a signal reports 128 plus the signal number, so 137 is 128 + 9. Signal numbers are for Linux on x86 and Arm; a few differ on macOS. 64-78 come from BSD's sysexits.h, which some tools follow and many ignore. Read the last status with echo $? in a shell.

128 plus the signal

When a signal kills a process, the shell reports 128 plus the signal's number. 130 is SIGINT from Ctrl+C, 137 is SIGKILL, 139 is SIGSEGV and 143 is SIGTERM. In Kubernetes, 137 with the reason OOMKilled means the container went over its memory limit; 143 is a normal shutdown request that the app should handle by finishing work and exiting. Signal numbers are listed in signal(7).

127 and 126

127 means the command was not found: a typo, a missing PATH entry under cron or systemd, or a script whose #! line names an interpreter that does not exist, which is also what a Windows line ending in a script produces. 126 means it was found but could not be executed, usually a missing execute permission.

Share

Frequently asked questions

What does exit code 137 mean?
The process was killed with SIGKILL (128 + 9). In Docker and Kubernetes this is most often the out-of-memory killer, shown as OOMKilled.
How do I see the exit code of the last command?
echo $? in a POSIX shell, or $LASTEXITCODE in PowerShell. docker inspect shows a container's in .State.ExitCode.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Go deeper

Suggested reading

Keep planning

Similar tools