Consider a process P that executes the fork system call twice. That is, it…

Consider a process P that executes the fork system call twice. That is, it runs code like this:

int ret1 = fork(); int ret2 = fork();

How many direct children of P (i.e., processes whose parent is P) and how many other descendants of P (i.e., processes whoare not direct children of P, but whose grandparent or great grandparent or some such ancestor is P) are created by the above lines of code? You may assume that all fork system calls succeed.

  1. A.

    Two direct children of P are created.

  2. B.

    Four direct children of P are created.

  3. C.

    No other descendant of P is created.

  4. D.

    One other descendant of P is created.

Attempted by 22 students.

Sign up free to check your answer

Sign up free

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…