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
- A.
3
- B.
4
- C.
7
- 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.