9

Yet another parent-child fork() dilemma [migrated]

view full story
linux-howto

http://unix.stackexchange.com – #include<stdio.h> int main() { int pid,dip; pid=fork(); if(pid==0) { printf("1st child's process id is %d \n",getpid()); printf("first child dead"); } else { dip=fork(); if(dip==0) { printf("2nd child process id is %d\n",getpid()); printf("Second child dead"); } else { printf("Child with pid %d died \n",wait(0)); printf("Child with pid %d died \n",wait(0)); printf("I am the parent"); } } return 0; } i think output should be first child process should be executed the second child then parent but on compiling it gives th (HowTos)