What is a zombie process and how is it created?
A zombie is a process that has already exited but whose exit status the parent hasn't collected yet — so the kernel keeps an empty entry for it.
* Zombie = exited-but-unreaped (parent forgot to wait()); orphan = still-running with a dead parent, adopted by PID 1. *
When a process exits, it doesn't vanish instantly. The kernel needs to hand the exit code back to the parent (did the child succeed or fail?). So it keeps a tiny placeholder — just the PID and exit status — until the parent calls wait() to read it. That placeholder is the zombie.
Lifecycle:
- Child calls
exit()— its memory and resources are released - Kernel retains a minimal entry (PID + exit status)
- Parent is supposed to call
wait()to "reap" it, which frees the entry - If the parent never reaps it, the zombie lingers
Why it's harmless yet annoying:
- It uses no CPU or memory — it's already dead
- It only occupies a slot in the process table (which is finite)
- It shows state
Zinps - You can't kill it — there's nothing to kill;
kill -9does nothing to a corpse
So how do you clear zombies? You go after the parent. Either fix the buggy parent to call wait(), or kill the parent. When the parent dies, its zombie children are re-parented to PID 1, which reaps them automatically.
Orphans vs zombies (easy to confuse): an orphan is a process that's still running but whose parent has died; PID 1 adopts it and will reap it when it eventually exits. A zombie has already exited and is waiting to be reaped.
Tip: A pile of zombies almost always means one buggy parent program that forgot to wait().
Go deeper:
Process state — zombie (Wikipedia) — the exited-but-unreaped entry, the wait() reap, and re-parenting to PID 1.