VOOZH about

URL: https://www.geeksforgeeks.org/c/zombie-and-orphan-processes-in-c/

⇱ Zombie and Orphan Processes in C - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Zombie and Orphan Processes in C

Last Updated : 21 Aug, 2025
Prerequisite: fork() in C A process which has finished the execution but still has entry in the process table to report to its parent process is known as a zombie process. A child process always first becomes a zombie before being removed from the process table. The parent process reads the exit status of the child process which reaps off the child process entry from the process table. In the following code, the child finishes its execution using exit() system call while the parent sleeps for 50 seconds, hence doesn’t call wait() and the child process’s entry still exists in the process table. Note that the above code may not work with online compiler as fork() is disabled.   A process whose parent process no more exists i.e. either finished or terminated without waiting for its child process to terminate is called an orphan process. In the following code, parent finishes execution and exits while the child process is still executing and is called an orphan process now. However, the orphan process is soon adopted by init process, once its parent process dies.
Note that the above code may not work with online compilers as fork() is disabled. Related : Any idea What are Zombies in Operating System? Zombie Processes and their Prevention
Comment
Article Tags: