Change in Process Id after fork
Hi,
Why Process Id(PID) is incremented 1 after creating a child process?
Consider the following and its corresponding outputs.
#include<stdio.h>
main()
{
int pid;
int pid_fork;
pid = getpid();
printf("\n Process Id is %d \n",pid);
pid_fork = fork();
if(pid_fork !=0)
printf("\n Process Id after fork %d \n",pid_fork);
}
Output
Process Id is 28770
Process Id after fork 28771
Thanks in advance
|