Zombie process

1 minute read

Zombie process is the process that finished execution but still has an entry in the process table; and the exit status has not been read by the parent process, i.e. when a child dies, the parent receives a SIGCHLD signal but chose to ignore it as I have mentioned in this post.

We can see the zombie process as ‘defunt’ or ‘Z’ status with $ps command.

$ ps a
  PID TTY      STAT   TIME COMMAND
 3618 pts/0    Z+     0:00 [my_zombie] <defunct>
 3623 pts/1    R+     0:00 ps a

In general, zombie process does not usually cause any serious impact to the system, unless there are large number of zombie processes in the system, as these processes can take up the finite number of PID and memory resources and prevent new process from launching.

Since zombie process is already dead, we can’t kill it, i.e. via SIGKILL. There are 2 ways we can handle the zombie process:

  1. Send SIGCHLD to its parent to let it know that one of its children has terminated, and request it to collect child’s exit status. The parent process can catch the SIGCHLD with the waitpid() or wait() call (This signal can be ignored though).
  2. Kill the parent process so that its zombie child process will become orphan processes and then adopted by the init process, and the init process will clean up these processes.

Leave a comment