fork return -1 0 else, if (pid < 0) break; " , ".
, , - :
i=0, . p0.
fork(); p0 . p1.
i++ ( i 1), .
p0 p1, , fork();, . p2 p3.
i++, i 2, .
4 , , fork(); . p4, p5, p6, p7.
Each process increments it ito 3, and then, since the condition of the cycle is now false, the cycle finally ends.
Now process 8 arrives (separately) on the next line.
(In fact, each iteration doubles the number of processes, so if you change 3to, for example, 15you will have 2 ^ 15 processes at the end.)
source
share