#include<stdio.h>
#include<sys/types.h>
void main()
{
pid_t pid;
pid = fork();
if (pid==0)
{
printf("\n Child is executing... \n");
printf("\n Child Process id is : %d \n",getpid());
printf("\n Parent Process id is : %d \n",getppid());
}
else if(pid>0)
{
printf("\n Parent is exectuting... \n");
printf("\n Parent Process id is : %d \n",getpid());
}
else
{
printf("Error!");
}
}
#include<sys/types.h>
void main()
{
pid_t pid;
pid = fork();
if (pid==0)
{
printf("\n Child is executing... \n");
printf("\n Child Process id is : %d \n",getpid());
printf("\n Parent Process id is : %d \n",getppid());
}
else if(pid>0)
{
printf("\n Parent is exectuting... \n");
printf("\n Parent Process id is : %d \n",getpid());
}
else
{
printf("Error!");
}
}
No comments:
Post a Comment