Open Hanochsunil opened 5 months ago
void main(){ pid_t pid; pid = fork(); if(pid==0){ printf("pid of child: %d\npid of parent of child: %d\n",getpid(),getppid()); } if(pid > 0){ wait(NULL); printf("pid of parent: %d\npid of parent of parent: %d\n",getpid(),getppid()); } }
include
include<sys/wait.h>
include<sys/types.h>
include
void main(){ pid_t pid; pid = fork(); if(pid==0){ printf("pid of child: %d\npid of parent of child: %d\n",getpid(),getppid()); } if(pid > 0){ wait(NULL); printf("pid of parent: %d\npid of parent of parent: %d\n",getpid(),getppid()); } }