retagged by
3,397 views
7 votes
7 votes

Consider a parent process $P$ that has forked a child process $C$. $C$ has again forked another child process $D$. Now $P$ terminates while $C$ and $D$ are still running. In this case, which of the following statements is true?

  1. $P$ immediately becomes a zombie process, until reaped by its parent
  2. Only process $C$ becomes a zombie process, until adopted by the init process
  3. Both process $C$ and $D$ becomes a zombie process, until adopted by the parent process of $P$
  4. $P$ immediately becomes an orphan process, until adopted by its parent
retagged by

2 Answers

7 votes
7 votes

A process is called a zombie process, if it is terminated but it's entry still exists in the Process Table, because it has to pass it's exit status to the the parent process

=> Only a terminated process can be a zombie process, which makes Option A our answer.


Processes C and D can't be zombie processes as they're not yet terminated. Process P can't be an orphan, as nowhere it is mentioned that it's parent has terminated.

 

Source: Galvin, page 121.

0 votes
0 votes

(A) is the correct option!

Zombie Process: 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.

Reference: https://www.geeksforgeeks.org/double-forking-prevent-zombie-process/

If the parent decides not to wait for the child’s termination and it executes its subsequent task, then at the termination of the child, the exit status is not read. Hence, there remains an entry in the process table even after the termination of the child. This state of the child process is known as the Zombie state.

Answer:

Related questions

5 votes
5 votes
8 answers
2
admin asked Oct 25, 2019
3,402 views
Consider the following piece of C code: void main( ) { fork( ); fork( ); exit( ); }How many child processes are created upon execution of this program?
4 votes
4 votes
1 answer
3