I was roaming through the Interprocess communication in Unix when i found something which can be shared:
i am just copying and pasting it here:
Child Process Termination
Once we have created a child process, there are two possibilities. Either the parent process exits before the child, or the child exits before the parent. Now, Unix’s semantics regarding parent-child process relations state something like this:
- When a child process exits, it is not immediately cleared off the process table. Instead, a signal is sent to its parent process, which needs to acknowledge it’s child’s death, and only then the child process is completely removed from the system. In the duration before the parent’s acknowledgment and after the child’s exit, the child process is in a state called “zombie”.
- When a process exits (terminates), if it had any child processes, they become orphans. An orphan process is automatically inherited by the ‘init’ process (process number 1 on normal Unix systems), and becomes a child of this ‘init’ process. This is done to ensure that when the process terminates, it does not turn into a zombie, because ‘init’ is written to properly acknowledge the death of its child processes.
When the parent process is not properly coded, the child remains in the zombie state forever. Such processes can be noticed by running the ‘ps’ command (shows the process list), and seeing processes having the string “<defunct>” as their command name.