MODELDRIFT.WATCH

Question 13 · Oct 3 · Day 24

Gemini on Question 13, Oct 3

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

The reason a zombie process won't respond to SIGTERM (or even kill -9 / SIGKILL) is because it is already dead.

A zombie process (marked with a Z or defunct in process lists) is simply a leftover entry in the system's process table. It has finished executing, but its parent process hasn't checked its exit status yet.

To get rid of a zombie, you cannot target the zombie itself; you must target its parent process.

Here is the step-by-step guide to clearing a zombie process:

Step 1: Find the Parent Process ID (PPID)

You need to find out which process spawned the zombie. Run the following command, replacing <ZOMBIE_PID> with the ID of your zombie process:

ps -o ppid= -p <ZOMBIE_PID>

Alternatively, to see all zombies and their parents, run:

ps -eo pid,ppid,stat,cmd | awk '$3=="Z"'

(The second column is the Parent PID).

Step 2: Nudge the Parent Process (Safe Method)

Sometimes, the parent process is just hanging and needs a reminder to clean up its dead children. You can send a SIGCHLD signal to the parent. This tells the parent, "Hey, your child died, read its status."

kill -s SIGCHLD <PARENT_PID>

Check if the zombie is gone. If it is still there, move to Step 3.

Step 3: Kill the Parent Process (Aggressive Method)

If the parent process is poorly written or completely frozen, it will never clean up the zombie. The only way to remove the zombie is to kill the parent process.

When a parent process dies, its zombie children are "adopted" by the system's init process (PID 1), which automatically and instantly cleans them up.

First, try terminating the parent gracefully:

kill -15 <PARENT_PID>

If the parent won't die, force kill the parent:

kill -9 <PARENT_PID>

⚠️ WARNING: Before you kill the parent process, check what it is! If the parent is a critical service (like a database manager or web server), killing it will bring down that service.

What if the Parent is PID 1 (init or systemd)?

If the PPID is 1, do not kill it. Killing PID 1 will crash your system.
If PID 1 is the parent of a zombie, it usually means the system is under extreme load or dealing with a kernel/driver bug. In this rare scenario, the only way to clear the zombie is to reboot the server.

Are you sure it's a Zombie (Z)?

Often, people confuse a Zombie process (Z state) with a process in Uninterruptible Sleep (D state).

  • •If top or ps shows the state as D, it is not a zombie. It is a living process that is stuck waiting for hardware I/O (like a failing hard drive or an unresponsive network share).
  • •You cannot kill a D state process with SIGKILL. You either have to fix the hardware/network issue it is waiting on, or reboot the machine.

sha256 ebf5b00a53fa… · 18 tokens in · 2,029 out · 17.2 s · via Google · 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
google/gemini-3.1-pro-preview
pinned google/gemini-3.1-pro-preview-20260219; alias resolved to google/gemini-3.1-pro-preview-20260219 at 2026-10-03 09:00:07 UTC (matches the pin)
Date
2026-10-03 · run 20261003T090008Z-b2d35e · scorer v1
Scored
answered
sha256
ebf5b00a53fa2db0fed6a45d92d2e2f3ad50aaf83954f8bc2396c930ee13c2b1
Permalink
https://modeldrift.watch/r/2026-10-03/R1/google/gemini-3.1-pro-preview/
Scored
answered
Received
2026-10-03 09:05:17 UTC
Run
20261003T090008Z-b2d35e
Served by
Google · HTTP 200 · finish stop
Size
2,806 characters · 2,029 tokens out incl. hidden reasoning · 17.2 s
The reason a zombie process won't respond to `SIGTERM` (or even `kill -9 / SIGKILL`) is because **it is already dead**.
A zombie process (marked with a `Z` or `defunct` in process lists) is simply a leftover entry in the system's process table. It has finished executing, but its **parent process** hasn't checked its exit status yet.
To get rid of a zombie, you cannot target the zombie itself; **you must target its parent process.**
Here is the step-by-step guide to clearing a zombie process:
### Step 1: Find the Parent Process ID (PPID)
You need to find out which process spawned the zombie. Run the following command, replacing `<ZOMBIE_PID>` with the ID of your zombie process:
```bash
ps -o ppid= -p <ZOMBIE_PID>
```
*Alternatively, to see all zombies and their parents, run:*
```bash
ps -eo pid,ppid,stat,cmd | awk '$3=="Z"'
```
*(The second column is the Parent PID).*
### Step 2: Nudge the Parent Process (Safe Method)
Sometimes, the parent process is just hanging and needs a reminder to clean up its dead children. You can send a `SIGCHLD` signal to the parent. This tells the parent, "Hey, your child died, read its status."
```bash
kill -s SIGCHLD <PARENT_PID>
```
Check if the zombie is gone. If it is still there, move to Step 3.
### Step 3: Kill the Parent Process (Aggressive Method)
If the parent process is poorly written or completely frozen, it will never clean up the zombie. The only way to remove the zombie is to **kill the parent process**.
When a parent process dies, its zombie children are "adopted" by the system's `init` process (PID 1), which automatically and instantly cleans them up.
First, try terminating the parent gracefully:
```bash
kill -15 <PARENT_PID>
```
If the parent won't die, force kill the parent:
```bash
kill -9 <PARENT_PID>
```
⚠️ **WARNING:** Before you kill the parent process, check what it is! If the parent is a critical service (like a database manager or web server), killing it will bring down that service.
### What if the Parent is PID 1 (`init` or `systemd`)?
If the PPID is `1`, **do not kill it**. Killing PID 1 will crash your system.
If PID 1 is the parent of a zombie, it usually means the system is under extreme load or dealing with a kernel/driver bug. In this rare scenario, the only way to clear the zombie is to **reboot the server**.
### Are you sure it's a Zombie (Z)?
Often, people confuse a Zombie process (`Z` state) with a process in **Uninterruptible Sleep (`D` state)**.
* If `top` or `ps` shows the state as **D**, it is not a zombie. It is a living process that is stuck waiting for hardware I/O (like a failing hard drive or an unresponsive network share).
* You cannot kill a `D` state process with `SIGKILL`. You either have to fix the hardware/network issue it is waiting on, or reboot the machine.

End of response · 50 lines · 2,806 characters · sha256 ebf5b00a53fa2db0fed6a45d92d2e2f3ad50aaf83954f8bc2396c930ee13c2b1