Skip to content
Latchkey

Exit Codes Cheat Sheet: Shell Status Codes Explained

What each shell exit code means and how to debug a failing CI step.

The exit status conventions that decide whether a CI step passes or fails.

Common codes

CodeMeaning
0Success
1General error
2Misuse of shell builtin / bad args
126Command found but not executable
127Command not found
128Invalid exit argument
255Out-of-range exit status

Signal-derived (128 + N)

CodeSignal
130SIGINT (Ctrl-C)
137SIGKILL (often OOM-killed)
139SIGSEGV (segfault)
143SIGTERM

Reading status

Terminal
cmd; echo "$?"          # last exit code
if cmd; then ok; else fail; fi
set -e                  # exit on first non-zero
trap 'echo failed: $?' ERR

Key takeaways

  • 0 is success; any non-zero is failure to CI.
  • 137 usually means an OOM kill (SIGKILL) - common in tight containers.
  • Codes 128+N map to signal N (130 = Ctrl-C, 143 = SIGTERM).

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →