EMZETT.
Login

Zombie process

In short: A zombie process is an already finished process whose entry in the process table still exists because the parent process has not yet collected its result.

In more detail: When a process ends, its exit code stays behind until the parent queries it with wait(). Until then the entry shows as “Z” (defunct) in the process list. It uses hardly any memory but occupies a process ID.

In Depth

  • Spotting: ps aux shows status Z; top shows the number of zombies.
  • Cannot be killed: A zombie is already dead. It is fixed when the parent calls wait() or is terminated.
  • Orphans: If the parent dies first, init/systemd adopts the child and cleans it up.
  • Containers: If a program that does not reap children runs as process 1, zombies accumulate. Helpers such as tini solve that.
  • Danger: Very many zombies can exhaust process IDs.

See also: Process scheduling