Friday, October 3, 2008

Why are there zombie process?

The fork call will create a child process which is independent from its parent. UNIX allows the parent process to synchronize its process with the child process via the wait call. As the system cannot predict if the parent process will execute wait call for the child or not, UNIX will not release all the resources when a process terminates in case its parent executes wait later on.  The termination status (normal or abnormal) of the child process and its resource statistics will be kept for the wait call.

Terminated process which has not been waited for becomes a zombie process. If the parent terminates without executing the wait call for its child, the child zombie process becomes an orphan process. Orphan process will be adopted by the init process (PID=1). init will call wait periodically and this is the mechanism UNIX uses to clean up zombie processes.

No comments: