With Extreme Prejudice
Sometimes a process is stuck in an infinite loop, has a deadlocked mutex, or is simply ignoring SIGTERM. You need it gone immediately.
SIGKILL (Signal 9) is fundamentally different from all other signals. It is not delivered to the process — it is delivered to the kernel as an instruction to forcibly destroy the process, invoked as kill -9 <pid> or the equivalent kill -KILL <pid>. The process never sees this signal. It has no opportunity to run cleanup code. The kernel immediately:
1. Removes the process from the scheduler.
2. Releases all its memory.
3. Closes all its file descriptors.
4. Leaves the process in zombie state until the parent calls wait().
SIGKILL cannot be caught, blocked, or ignored. This is by design — there must always be a way to terminate a misbehaving process. The only exception is D-state processes, which cannot receive any signals until their kernel operation completes.
The cost of SIGKILL:
| Resource | What happens |
|---|---|
| In-memory data not yet flushed to disk | Lost |
| Temporary files created by the process | Left behind |
| Database write-ahead log (WAL) | Incomplete transaction — DB must recover on next start |
| Network connections | Abruptly closed — peers see a TCP RST |
| Locks held by the process | Released by kernel — but application-level locks (e.g., a lockfile) are not |
The rule: Always try SIGTERM first. Give the process a few seconds. Only escalate to SIGKILL if it doesn't respond. This is exactly what systemctl stop does — it sends SIGTERM, waits TimeoutStopSec (default 90 seconds), then sends SIGKILL.
Interviewers ask: "What's the difference between kill -9 and kill -15?" The shallow answer is "one is forceful, one is polite." The senior answer is: SIGTERM is delivered to the process and can be caught/handled, allowing graceful shutdown. SIGKILL is delivered to the kernel and cannot be caught, blocked, or ignored — the kernel forcibly destroys the process with no cleanup opportunity. The practical implication: SIGKILL can leave lockfiles, incomplete transactions, and corrupted state behind. Always prefer SIGTERM with a timeout.