Can anyone help me in writing the code to create an orphan process......?? ??
Code to create an orphan process?
Collapse
X
-
It creates process which is addopted by init when parent has finished. Child process is working in unfinite loop (but you can of course change it).Code:#include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <stdlib.h> #include <sys/wait.h> int main(){ pid_t i; i=fork(); if (i==0){ while (1){ printf("child process pid = %d, ppid=%d\n",(int)getpid(), (int)getppid()); sleep(3); } }else{ printf("parent has finished"); } return 0; }
Is that what you want?Comment
Comment