标签:== int pre \n pip include else waitpid stdio.h
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
int main(void){
pid_t P1, P2, P3;
printf("I am father, My ID is %d.\n", getpid());
P1=fork();
if(P1==0)
printf("I am son1, my ID is %d.\n", getpid());
else
waitpid(P1,NULL,0);
P2=fork();
if(P2==0)
printf("I am son2, my ID is %d.\n", getpid());
else
waitpid(P2,NULL,0);
P3=fork();
if(P3==0)
printf("I am son3, my ID is %d.\n", getpid());
else
waitpid(P3,NULL,0);
}
标签:== int pre \n pip include else waitpid stdio.h
原文地址:https://www.cnblogs.com/yocichen/p/9737993.html