Created
June 18, 2017 07:24
-
-
Save bhavul/4350799e41ef2f023f80e3d44474949d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <sys/types.h> | |
#include <unistd.h> | |
int main() | |
{ | |
if(fork()) //1st child p2 created | |
{ | |
printf("after first fork. pid : %d\n", getpid()); | |
if(fork()) //2nd child p3 created | |
{ | |
printf("after second fork, pid: %d\n", getpid()); | |
fork(); //3rd child p4 created | |
printf("after third fork, pid: %d\n", getpid()); | |
} | |
printf("getting out of if, pid: %d\n", getpid()); | |
} | |
printf("outermost, pid: %d\n", getpid()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment