in Operating System retagged by
2,350 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
in Operating System retagged by
2.4k views

2 Answers

6 votes
6 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.

3 Comments

@JashanArora can we say that process C has become orphan here, since its parent P is terminated.

0
0

A process is an orphan when it's parent terminated without calling wait().

And therefore this child whose parent terminated has no one to pass its exit status to.

Technically, the question doesn't tell us if P terminated with a wait() system call or not. So, data is insufficient, I think.

 

But generally parent processes do call wait(), so a god probabilistic guess would be — No, C doesn't become an orphan.

 

This topic is slightly detailed, I'd advise you to read Galvin (get a pdf of it online :P)

0
0

Ok Thank You!!! @JashanArora

0
0
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.

4 Comments

edited by
Ok.
0
0
Verify pls:

1. P become a zombie process until report to its parent process

2. C also become zombie process until adopted by init process

3. D doesn’t become zombie bcz it has C as it’s parent.
0
0

@chauhansunil20th

Who is the parent of P? Not all processes have a parent right? Then what if P is that process which doesn't have any parent as nothing is mentioned? Will this hold then also?

0
0
Answer:

Related questions