Hackintoshrao:codes for GNU/LINUX ILLUSTRATION OF ORPHAN PROCESS AND ASSIGNMENT OF INIT AS A PARENT TO SUCH A PROCESS SYSTEM CALLS USED 1.fork() 2.getpid() 3.getppid() 4.sleep() */ #include<stdlib> #include<unistd> #include<time> int main() { int pid; pid=fork(); if(pid==0) { printf("\nChild process here \n"); printf("\nchild here..Parent id=%d,Process id=%d\n",getppid(),getpid()); sleep(3); printf("\nChild process here,now its a orphan process,so init is my parent process now \n"); printf("\nchild here...Parent id=%d,Process id=%d\n",getppid(),getpid()); /*its clearly evident in the o/p that the parent process Id of the child process will now be =1, the init process is made as a parent */ } else{ sleep(1); /*since parent process finishes earlier than the child ,the latter becomes a orphan process */ printf("\nparent process here \n"); printf("\nparent process..Process id=%d\n",getpid()); printf("\nparent process Exiting,making the child process a orphan .......\n\n") ; } }