1 votes 1 votes void forkexample() { // child process because return value zero if (fork() == 0) printf("Hello from Child!\n"); // parent process because return value non-zero. else printf("Hello from Parent!\n"); } int main() { forkexample(); return 0; } Please someone explain how things are working? Operating System operating-system fork-system-call + – iarnav asked Oct 17, 2018 iarnav 823 views answer comment Share Follow See all 4 Comments See all 4 4 Comments reply Shaik Masthan commented Oct 17, 2018 reply Follow Share check the links which is provided in the answer https://gateoverflow.in/242749/self-doubt 1 votes 1 votes Shaik Masthan commented Oct 17, 2018 reply Follow Share check this also https://gateoverflow.in/145738/self-doubt-os-fork?show=145738#q145738 1 votes 1 votes iarnav commented Oct 18, 2018 reply Follow Share @shaik, thank you bhai, I'll see those links. 0 votes 0 votes shaktisingh commented Jun 30, 2019 reply Follow Share output will be : Hello from child! Hello from parent! or Hello from parent! Hello from child! 1 votes 1 votes Please log in or register to add a comment.
1 votes 1 votes OUTPUT: Hello from child! Hello from parent! or Hello from parent! Hello from child! Because we dont know wheather parent executed first or child. Sanandan answered Aug 28, 2020 Sanandan comment Share Follow See all 0 reply Please log in or register to add a comment.