Lesson 8 of 20 · 18m
Signals and the Process Lifecycle: kill Is a Request
kill(2) is a request, SIGKILL is a kernel teardown, and PID 1 reaps zombies — the lifecycle rules Docker's grace period is built on.
kill(2) sends a request, not an order
The command is named kill, so everyone assumes it kills. What it actually does is deliver a signal — a small integer the kernel drops into the target task's pending-signal set. What happens next depends on what the process registered for that signal. SIGTERM (15) defaults to termination but is fully catchable; a process can install a handler that flushes buffers, drops locks, and exits cleanly — or a handler that ignores it entirely. SIGKILL (9) is the exception: it can't be caught, blocked, or ignored, because userspace never sees it — the kernel just schedules the task for teardown.
That distinction explains the entire lifecycle drama of production services. docker stop sends SIGTERM, waits the grace period (10 s default; Kubernetes terminationGracePeriodSeconds defaults to 30), then sends SIGKILL. An app with no SIGTERM handler doesn't shut down politely — it wastes the whole window and then dies mid-write anyway. A five-line handler and an honest trap in bash turns "mysterious 30-second deploy stall plus truncated state file" into "process exited in 200 ms with clean state."
Signals you'll actually meet
SIGINT(2): Ctrl-C. Catchable; shells forward it to the foreground process group.SIGHUP(1): originally "your modem hung up" — the convention became "reload config" for daemons.systemctl reload nginxandkill -HUPboth mean this.SIGCHLD(17): parent notification that a child changed state — the hookwait()hangs on.SIGSTOP/SIGCONT(19/18): uncatchable pause/resume;SIGTSTPis the catchable version Ctrl-Z sends.SIGPIPE(13): writing to a closed pipe delivers this — why a| headpipeline makes the left side die quietly.SIGSEGV(11),SIGBUS(7): memory violations; the ones that leave core dumps.
kill -l prints the full table. kill is both a bash builtin and /bin/kill — same syscall either way.
Zombies: the exit nobody collected
When a process exits, it leaves a task skeleton holding its exit code until a parent calls wait() to collect it. That's a zombie (Z state) — already dead, consuming no CPU, just an unreaped row in the task table. Orphans get reparented to PID 1, whose job includes reaping them.
This is where containers invented a fresh bug. A container's PID namespace makes your app PID 1 — and PID 1 has special duties. Most app runtimes never call wait() on adopted orphans, so every grandchild that dies stays a zombie forever. Run enough cron jobs or exec calls and pids.max arrives with a container full of [sh] <defunct>. Docker's --init flag drops in tini, a 20-kilobyte init whose only job is forwarding signals and reaping zombies; Kubernetes does it via shareProcessNamespace or a container runtime with an init. If your "container keeps getting slower" report shows hundreds of zombies, the fix isn't more memory — it's a real PID 1.
D-state: where even SIGKILL waits
SIGKILL ends a task the next time it's schedulable. If the task is in D — uninterruptible sleep inside a syscall, classically a dead NFS mount or a wedged block device — it can't run, so the kill pends until the syscall returns. Which may be never. This is why "even kill -9 doesn't work" is a real support ticket, and why the fix is umount -f/umount -l or a reboot, not a bigger signal.
Process groups and job control
Signals aim at a process group when you call kill(-pgid, sig) — setsid creates a new session and group, which is how daemons detach from your login's fate. pkill -g, kill -- -12345, and the shell's job control (Ctrl-Z → SIGTSTP, bg → SIGCONT) all operate on groups, which is why killing a pipeline doesn't always kill its members.
Try this
sleep 300 & kill -TSTP $!; ps -o pid,stat,cmd -p $!; kill -CONT $!
(sleep 1; exit 7) & wait $!; echo $? # reaping in your own shell
docker run --rm --init alpine sh -c 'sleep 5' # tini as PID 1Field notes
The kill -9 reflex deserves its reputation: Postgres distinguishes smart (wait for clients), fast (rollback, checkpoint, exit), and immediate (kill-style, needs recovery) shutdowns precisely because hard-killing a database mid-checkpoint costs you a crash-recovery pass — or a corrupted page on an unlucky day. Send SIGTERM, give it the documented grace window, escalate only when it ignores you.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
Red Hat Called This Bug a 5.9. Two Weeks Later It Was a 9.8.
CVE-2026-98432 is a use-after-free in the IPv4 TCP handshake, reachable by anybody who can reach a listening port, sitting in the kernel since 4.4. Red Hat scored it 5.9 moderate and deferred the fix. Then 8.1. Then 9.8.
Januscape: A 16-Year-Old Linux KVM Escape Bug
CVE-2026-53359 lets a guest VM crash or potentially root your Proxmox host, and it hid in KVM's shared code for 16 years. What to patch and how to check.
CVE-2026-31431 "Copy Fail": How a 9-Year-Old Linux Kernel Bug Gives Any Local User Root in 732 Bytes
CVE-2026-31431 chains AF_ALG, splice(), and authencesn's ESN scratch write into a deterministic 4-byte page cache write that gives an unprivileged local user root. Full technical breakdown, exploit mechanics, detection, mitigation, and patch status per distro.
Self-Host OpenClaw: VPS Setup to Production (2026)
Self-host OpenClaw from zero to production. Server provisioning, SSH lockdown, Docker, reverse proxy, Fail2ban, performance tuning, and full backup strategy in one guide.