A process executes the code fork(); fork(); fork(); the total number of child…

20122025

A process executes the code

fork();

fork();

fork();

the total number of child processes created is

  1. A.

    3

  2. B.

    4

  3. C.

    7

  4. D.

    8

Attempted by 564 students.

Show answer & explanation

Correct answer: C

Key idea: Each call to fork() doubles the number of processes.

  • Start with 1 process (the original parent).

  • After three fork() calls, total processes = 2^3 = 8.

  • Child processes = total processes − original parent = 8 − 1 = 7.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Gate Guidance By Sanchit Sir