#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
main(){
int p1, p2;
int i = 1;
while ((p1 = fork()) == -1);
if (p1 == 0)
printf("%s “, “child1”);
else
{
while ((p2 = fork()) == -1);//在父进程下创建第二个子进程
if (p2 == 0) //是子进程?
printf(”%s “, “child2”);
else{ //父进程
printf(”%s ", “parent”);
}
}
}
222222222222
最新推荐文章于 2024-09-28 15:38:29 发布