0 votes 0 votes pid=fork(); if (pid !=0) fork(); fork(); no . of child process are created when above program are executed.? Shubham Aggarwal asked Jan 15, 2019 Shubham Aggarwal 630 views answer comment Share Follow See all 13 Comments See all 13 13 Comments reply Shobhit Joshi commented Jan 15, 2019 reply Follow Share $4?$ 0 votes 0 votes Kunal Kadian commented Jan 15, 2019 reply Follow Share 5 ? Whats the ans given? 0 votes 0 votes Shubham Aggarwal commented Jan 15, 2019 reply Follow Share ans is 5 0 votes 0 votes Shubham Aggarwal commented Jan 15, 2019 reply Follow Share @Kunal Kadian explain how ??? 0 votes 0 votes balchandar reddy san commented Jan 15, 2019 reply Follow Share should be 4 0 votes 0 votes Shobhit Joshi commented Jan 15, 2019 reply Follow Share $5$ would be $4$ child + $1$ parent 0 votes 0 votes balchandar reddy san commented Jan 15, 2019 reply Follow Share yes..the answer must be 4 as they have asked the number of child processes. 0 votes 0 votes Shobhit Joshi commented Jan 15, 2019 reply Follow Share @balchandar reddy san i think the same, let's see the explanation for $5$ maybe we missed something 0 votes 0 votes Shubhgupta commented Jan 15, 2019 reply Follow Share but scope of if will be present till first fork. so should be 5. 0 votes 0 votes Shobhit Joshi commented Jan 15, 2019 reply Follow Share got the mistake thanks ! 0 votes 0 votes balchandar reddy san commented Jan 15, 2019 reply Follow Share didn't get it..could you elaborate @Shobhit Joshi 0 votes 0 votes Kunal Kadian commented Jan 15, 2019 reply Follow Share Yes @Shubhgupta is Correct. That's why I answered it 5. 0 votes 0 votes Kunal Kadian commented Jan 15, 2019 reply Follow Share @balchandar reddy san try making a tree diagram and see. In if condition there is only 1 fork statement. The last fork statement is outside if. 0 votes 0 votes Please log in or register to add a comment.