#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main()
{
pid_t pid=0;
if((pid=fork())>0)
printf("I am the parent,my pid %u,my child's pid=%u/n",getpid(),pid);
else if (pid==0)
printf("I am the child,my pid=%u,my parent's id=%u/n",getpid(),getppid());
else
{
perror("fork");
return 1;
}
return 0;
}
#include <stdlib.h>
#include <unistd.h>
int main()
{
pid_t pid=0;
if((pid=fork())>0)
printf("I am the parent,my pid %u,my child's pid=%u/n",getpid(),pid);
else if (pid==0)
printf("I am the child,my pid=%u,my parent's id=%u/n",getpid(),getppid());
else
{
perror("fork");
return 1;
}
return 0;
}