Fork Parent Child Code

Fork Parent Child Code Execution Blocks

fork() will return -1 (to the would-be parent) if the fork doesnt work.
if((pid = fork()) < 0){
   //some sort of error occurred
   if(pid == 0){
     //child goes on from here
     //parent goes on from here

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License