Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Exit-Status Lifecycle and Conventions

This section traces a process from the moment it begins terminating to the moment another process (or a shell) observes a single integer summarizing what happened. It separates three layers that are often confused: termination (what the process itself does through exit(3), _exit(2), abort(3), or signal death), status collection (what the parent reads through wait(2), waitpid(2), or waitid(2) and how the kernel encodes it), and status reporting (what a shell’s $?, a service manager, or a container runtime ultimately surfaces). The same distinction explains why exit codes carry far less information than most practitioners assume.

PageCoverageIDs
Lifecycleexit/_exit/_Exit semantics, the wait family, the exact 16-bit wait-status bit layout on Linux, WIFEXITED/WEXITSTATUS/WIFSIGNALED/WTERMSIG/WCOREDUMP/WIFSTOPPED/WSTOPSIG/WIFCONTINUED macros, 8-bit truncation, zombies and reaping, stopped/continued childrenEX-001 – EX-009
ConventionsCommon status values (0, 1, 2, 126, 127, 128+N, 130, 137, 139, 143), what guarantees vs conventions vs tool-specific codes they are, and the additional evidence required before any single integer can be treated as a root causeEX-010 – EX-012

Scope and verification

Behavioral claims in this section are cited to wait(2), exit(3), _exit(2), and POSIX.1-2017 XCU §2.8, with the wait-status bit layout verified against the kernel UAPI header include/uapi/linux/wait.h. Claims about shell-visible statuses are cited to the shell manuals (Bash, Dash, Zsh) and are kept separate from kernel- and POSIX-level facts.

References