MODELDRIFT.WATCH

Question 13 · Oct 3 · Day 24

Claude on Question 13, Oct 3

How do I kill a zombie process in Linux that won't respond to SIGTERM?

The short answer: you can't kill a zombie — it's already dead

A zombie (shown as Z or <defunct> in ps) is a process that has already terminated. All it is at this point is an entry in the kernel's process table holding its exit status, waiting for its parent to call wait()/waitpid() and collect it. There's no running code, no memory map, nothing to signal. That's why SIGTERM and even SIGKILL do nothing.

The real problem is the parent process that isn't reaping its children.

Find the zombies and their parents

ps -eo pid,ppid,stat,comm | awk '$3 ~ /^Z/'

Or:

ps aux | grep -w defunct

The PPID column is what you care about.

Step 1: Nudge the parent

Send SIGCHLD to the parent to prompt it to reap:

kill -s SIGCHLD <PPID>

A well-behaved parent with a proper handler will call wait() and the zombie disappears. If nothing happens, the parent has a bug (lost/ignored SIGCHLD, blocked in a loop, never calls wait() at all).

Step 2: Kill or restart the parent

When the parent dies, its zombie children are re-parented to PID 1 (init/systemd), which reaps orphans automatically.

# graceful first
kill <PPID>

# or if it's a service
systemctl restart <service>

Only use kill -9 on the parent if a normal TERM fails — it skips cleanup handlers and can leave behind sockets, lock files, or temp data.

Step 3: If the parent is PID 1

If zombies are parented to systemd and persisting, something is genuinely wrong — that's usually a kernel or container-runtime issue. In containers this is common when your entrypoint is a shell script or app that isn't a proper init: run with docker run --init, or use tini/dumb-init as PID 1.

Make sure it's actually a zombie

People often confuse zombies with processes stuck in D state (uninterruptible sleep). Those genuinely ignore SIGKILL and do hold resources:

ps -eo pid,stat,wchan:20,comm | awk '$2 ~ /^D/'

D state means the process is blocked in a kernel call — typically a hung NFS mount, a failing disk, or a stuck device driver. You can't kill it; you have to fix the underlying I/O (remount with umount -f -l, restore network to the NFS server, replace the dying disk). cat /proc/<pid>/stack and dmesg will usually point at the cause.

Do you even need to fix it?

A handful of zombies is harmless — each consumes one process-table slot and a few hundred bytes. It only matters if they accumulate toward kernel.pid_max (check with sysctl kernel.pid_max), which eventually prevents new process creation. A steadily growing zombie count is a strong signal of a bug in the parent application worth reporting or patching.

Rebooting works as a last resort, but it's treating the symptom — the parent will do it again.

sha256 555132664498… · 33 tokens in · 1,709 out · 22.8 s · via Claude Platform on AWS · stopped on its own

Oct 3, the whole dayQuestion 13, every day

Exact recordShowHideThe model id, the run, the verbatim text with line numbers and its full sha256
Model
anthropic/claude-opus-5
pinned anthropic/claude-opus-5-20260723; alias resolved to anthropic/claude-opus-5-20260723 at 2026-10-03 09:00:07 UTC (matches the pin)
Date
2026-10-03 · run 20261003T090008Z-b2d35e · scorer v1
Scored
answered
sha256
555132664498f4f838e588b29fa0dd1ce3ef3c59dba159dea480bfd3f057c4f8
Permalink
https://modeldrift.watch/r/2026-10-03/R1/anthropic/claude-opus-5/
Scored
answered
Received
2026-10-03 09:05:00 UTC
Run
20261003T090008Z-b2d35e
Served by
Claude Platform on AWS · HTTP 200 · finish stop
Size
2,815 characters · 1,709 tokens out incl. hidden reasoning · 22.8 s
## The short answer: you can't kill a zombie — it's already dead
A zombie (shown as `Z` or `<defunct>` in `ps`) is a process that has already terminated. All it is at this point is an entry in the kernel's process table holding its exit status, waiting for its parent to call `wait()`/`waitpid()` and collect it. There's no running code, no memory map, nothing to signal. That's why `SIGTERM` and even `SIGKILL` do nothing.
The real problem is the **parent process** that isn't reaping its children.
## Find the zombies and their parents
```bash
ps -eo pid,ppid,stat,comm | awk '$3 ~ /^Z/'
```
Or:
```bash
ps aux | grep -w defunct
```
The `PPID` column is what you care about.
## Step 1: Nudge the parent
Send `SIGCHLD` to the parent to prompt it to reap:
```bash
kill -s SIGCHLD <PPID>
```
A well-behaved parent with a proper handler will call `wait()` and the zombie disappears. If nothing happens, the parent has a bug (lost/ignored `SIGCHLD`, blocked in a loop, never calls `wait()` at all).
## Step 2: Kill or restart the parent
When the parent dies, its zombie children are re-parented to PID 1 (`init`/`systemd`), which reaps orphans automatically.
```bash
# graceful first
kill <PPID>
# or if it's a service
systemctl restart <service>
```
Only use `kill -9` on the parent if a normal TERM fails — it skips cleanup handlers and can leave behind sockets, lock files, or temp data.
## Step 3: If the parent is PID 1
If zombies are parented to `systemd` and persisting, something is genuinely wrong — that's usually a kernel or container-runtime issue. In containers this is common when your entrypoint is a shell script or app that isn't a proper init: run with `docker run --init`, or use `tini`/`dumb-init` as PID 1.
## Make sure it's actually a zombie
People often confuse zombies with processes stuck in `D` state (uninterruptible sleep). Those genuinely ignore `SIGKILL` and *do* hold resources:
```bash
ps -eo pid,stat,wchan:20,comm | awk '$2 ~ /^D/'
```
`D` state means the process is blocked in a kernel call — typically a hung NFS mount, a failing disk, or a stuck device driver. You can't kill it; you have to fix the underlying I/O (remount with `umount -f -l`, restore network to the NFS server, replace the dying disk). `cat /proc/<pid>/stack` and `dmesg` will usually point at the cause.
## Do you even need to fix it?
A handful of zombies is harmless — each consumes one process-table slot and a few hundred bytes. It only matters if they accumulate toward `kernel.pid_max` (check with `sysctl kernel.pid_max`), which eventually prevents new process creation. A steadily growing zombie count is a strong signal of a bug in the parent application worth reporting or patching.
Rebooting works as a last resort, but it's treating the symptom — the parent will do it again.

End of response · 63 lines · 2,815 characters · sha256 555132664498f4f838e588b29fa0dd1ce3ef3c59dba159dea480bfd3f057c4f8