#include<stdio.h>#include<sys/types.h>#include<unistd.h>#include<sys/wait.h>intmain(){pid_t a;
a=fork();if(a>0){printf("father pid is %d\n",getpid());}elseif(a==0){sleep(2);printf("child pid is %d ppid is %d \n",getpid(),getppid());}return0;}
#include<stdio.h>#include<sys/types.h>#include<unistd.h>#include<sys/wait.h>intmain(){pid_t a;
a=fork();if(a>0){while(1){printf("father pid is %d\n",getpid());sleep(2);}}elseif(a==0){printf("child pid is %d ppid is %d \n",getpid(),getppid());}return0;}