Skip to content
Latchkey

kill -SIGTERM vs -SIGKILL: Signals in CI

kill -TERM asks a process to shut down cleanly while kill -KILL (-9) forces it; the exit codes 143 and 137 are the fingerprints those signals leave.

CI cleanup and timeouts both rely on signals. Knowing TERM vs KILL, and that the runner uses TERM first, explains the exit codes you see and how to shut a service down without corrupting state.

What it does

kill sends a signal to a PID; the default is SIGTERM (15), a polite request the process can trap to flush and exit. SIGKILL (9) cannot be caught and terminates immediately, risking lost work. A process killed by signal N exits with code 128+N: TERM gives 143, KILL gives 137.

Common usage

Terminal
kill 4242                        # SIGTERM (graceful) by default
kill -TERM 4242                  # explicit graceful stop
kill -9 4242                     # SIGKILL, force (last resort)
kill -0 4242                     # signal 0: just test if the PID exists
kill -- -<pgid>                  # signal a whole process group

Options

FormWhat it does
kill <pid>Send SIGTERM (graceful) by default
kill -9 / -KILLForce kill, cannot be trapped
kill -15 / -TERMRequest graceful shutdown
kill -2 / -INTSame as Ctrl-C (SIGINT)
kill -0 <pid>Test existence/permission, send no signal
kill -lList signal names and numbers

In CI

Exit 143 in logs means something sent SIGTERM, often a job cancel or timeout; exit 137 means SIGKILL, often the OOM killer or a hard timeout after the grace period. Give services a real SIGTERM handler so they flush before exit; reaching for kill -9 first can corrupt a database fixture mid-write. (The existing kill-command page covers the base command; this is the signals deep dive.)

Common errors in CI

"kill: (4242) - No such process" means the PID already exited. "kill: (4242) - Operation not permitted" means the process belongs to another user; use sudo. A process that ignores SIGTERM is either trapping and mishandling it or stuck in state D (uninterruptible I/O), where even SIGKILL waits until the I/O completes.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →