How many processes are forked here

后端 未结 4 817
不知归路
不知归路 2020-12-22 13:52

I know that it might come as a stupid question but could anyone help me understand the behavior of the following code snippet

//label 0
int main(){
  fork();         


        
4条回答
  •  -上瘾入骨i
    2020-12-22 14:31

    After the first fork, you have two processes. Both hit the second fork, creating four processes in total.

    All four hit the third fork, so you have eight processes. Then they all exit.

提交回复
热议问题