#include "stdio.h"
#include <unistd.h>
void main()
{
printf("hello word\n");
pid_t pid = fork();
int test1=0;
if(pid<0)
{
printf("creat process faild\n");
}
else if(pid ==0)
{
while(test1<7)
{
test1=test1+2;
printf(" father process %d \n",test1);
sleep(3);
}
}
else
{
while(test1<5)
{
test1++;
printf(" child process %d \n ",test1);
sleep(3);
}
}
}
执行结果: