Can somebody please explain when parent process receives the exit status of a dead child process via wait, who actually reallocates the memory of the child process and removes it from the process table?

2 Answers 2


Manipulating the process table and the memory mappings is always the kernel's job. The kernel acts when some process makes a system call. When a process exits, all of the resources that it uses, including memory, except for the entry in the process table, are deleted − that's what the _exit system call does. Then, when the parent process calls wait or waitpid, part of that system call's job is to clean up the process table entry. The parent process may decide to call wait whenever it wants (if the parent is init, it calls wait pretty much all the time).


The kernel assumes that the parent process is interested in knowing the result of any child process that it forked. When a child process terminates, it automatically sends a SIGCHLD signal to the parent process.  If the parent is explicitly ignoring the SIGCHLD signal, the child is immediately cleaned up and removed completely (and does not become a zombie). Otherwise, the child becomes a zombie until the parent calls one of the wait functions to retrieve termination status from the child.

If the status is not retrieved, child remains a zombie. However if the parent process exits before the child process, the child is adopted by init (process 1), which collects the status immediately, effectively removing the zombie process.

  • thank You, but what if the parent process doesn't exist before the child process, and father received status value, who will remove ZOMBIE? also init?
    – macindows
    Jun 29, 2011 at 12:33
  • @macindows: Yes. If the parent process doesn't exist, responsibility passes to its parent, then that process's parent, and so on. If no other ancestor process currently exists, it will end up with init.
    – Dave Sherohman
    Jun 29, 2011 at 14:43

You must log in to answer this question.