Counting the original process, how many processes exist after the C code for (int i = 0; i < 3; i++) fork(); has run?
Correct answer D. 8
Each fork() doubles the number of processes, because every existing process executes the next call. After one iteration there are 2, after two there are 4, and after three there are 2^3 = 8, including the original parent. The answer 3 counts only the calls, and 4 forgets that children created in earlier iterations also keep looping.
Answer checked How we write and check questions
Discussion