#include"myHeader.h" int main() { if(fork()) { if(fork()) { if(fork()) printf("parent id :%d\n",getpid()); else printf("child3 id: %d parent id:%d\n",getpid(),getppid()); } else printf("child2 id: %d parent id:%d\n",getpid(),getppid()); } else printf("child1 id: %d parent id: %d\n",getpid(),getppid()); }OutPut:
madan@madan-Lenovo-G570:~/madan/osconcepts$ ./a.out child1 id: 3514 parent id: 3513 parent id :3513 child2 id: 3515 parent id:3513 child3 id: 3516 parent id:1144