What happens when fork is called 3 times?

What happens when fork is called 3 times?
Answer
Parent process (main) must iterate the loop 3 times. Then printf is called. On each iteration of parent for-loop a fork() is called. After each fork() call, i is incremented, and so every child starts a for-loop from i before it is incremented.
 

Tìm kiếm

Back
Top