Wednesday, 9 September 2015

PR(07) C Program to Parent creating the child process by use of fork.



#include<stdio.h>
#include<sys/types.h>
void main(void)
{
pid_t pid;
printf("\nMain Process id is %d and main parent id is %d",getpid(),getppid());
pid=fork();
if(pid==0)
{
printf("\n In Child process");
printf("\nchild process id %d and parent id is %d",getpid(),getppid());
}
else
{

printf("\n In parent process");
printf("\nparent process id %d and parent id is %d",getpid(),getppid());
}
}

No comments:

Post a Comment