Bellow is the code of what is going on, and here is an image of what am i trying to do, any help would be appreciated. Trying to draw the diagram of all the processes Code:
for(i=0;i<2;i++){
int pid = fork();
if(pid == 0){
fork();
printf("\tA\n");
}
else{
printf("\tB\n");
}
}//for
printf("\tC\n");
return 0;
}
Mainly missing from your diagram is in the block Child1 as well as Child1.1 a second run through the for
loop, since these children are still inside the loop and their i
is initially also 0.
On the other hand, the C=3 in Parent is wrong because C is only printed once at the end, not in the loop.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.