Exit code 128: An invalid exit argument, or the base of the signal-encoded range
128 is the base from which signal-terminated exit codes are counted: a process killed by signal N reports 128 + N. A literal 128 is rare and usually means a program called exit with an out-of-range value.
Applies to: All Kubernetes versions, Linux nodes
What it means
When a process is terminated by a signal, the shell and the container runtime report its status as 128 plus the signal number — which is how 137 (128 + SIGKILL) and 143 (128 + SIGTERM) get their values. A bare 128 is not itself a signal termination, since there is no signal 0 in this sense. It normally appears when a program passes an invalid argument to exit, or when a shell script exits with a value outside 0–255 and the result wraps. Practically, the useful thing to know about 128 is the arithmetic: any container exit code above 128 should be read by subtracting 128 and looking up the signal.
Most common causes
- A shell script calling
exitwith a non-numeric or out-of-range argument. - An application returning a value from main that is outside the 0–255 range, which is truncated by the operating system.
- A wrapper script propagating an exit status incorrectly.
- Some runtimes reporting 128 when the true status could not be determined.
How to diagnose it
- Read the container's termination reason as well as the code:
kubectl describe pod PODunderLast State. If a signal was involved, the reason usually names it. - If the code is above 128, subtract 128 and look up the signal number in
signal(7)— 9 is SIGKILL, 15 is SIGTERM, 11 is SIGSEGV, 6 is SIGABRT. - Check any wrapper script for how it propagates the status of the process it launches.
- Read the logs for the real error, which is usually more informative than the code.
How to fix it
- Make wrapper scripts
execthe real process so its exit status is reported directly rather than translated. - Ensure any explicit
exitcall uses a value between 0 and 255. - Treat the arithmetic as the diagnosis: fix whatever caused the signal, not the code.
Notes
Because exit statuses are 8 bits, a program returning 256 reports 0 — a success that never happened. This is a real source of silently passing batch jobs and is worth checking in any script that computes an exit status.
Related
Sources
- GNU Bash Reference Manual — Exit Status
- Linux manual page — signal(7)
- Kubernetes documentation — Pod Lifecycle: container states