"); //-->
fork 以后 父进程和子进程 pid 不一样,其中子进程已经成为孤儿进程。可以参考下面两个链接了解。
https://www.cnblogs.com/chilumanxi/p/5136102.html
https://www.cnblogs.com/chilumanxi/p/5136102.html



#include <stdio.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc,char *argv[]){
pid_t pid;
pid = fork();
if(pid == 0)
{
printf("Here is child,my pid = %d,my parent pid = %d\r\n",getpid(),getppid());
exit(0);
}else if(pid > 0)
{
printf("here is parent,my pid = %d,child's pid = %d\n",getpid(),pid);
}else{
perror("fork error\n");
}
return 0;
}*博客内容为网友个人发布,仅代表博主个人观点,如有侵权请联系工作人员删除。