#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/wait.h>
int main(int argc, const char *argv[])
{
pid_t pid=fork();//创建子进程
if(pid>0)
{
printf("this a little father%d\n",getpid());
_exit(0);
}
else if(pid==0)
{
int i=0;
while(i<3){
printf("this a little father%d,child:%d\n",getppid(),getpid());
sleep(1);
i++;
}
}
else
perror("fork");
return 0;
}
~