fork 一個(gè) 孤兒進(jìn)程
fork 以后 父進(jìn)程和子進(jìn)程 pid 不一樣,其中子進(jìn)程已經(jīng)成為孤兒進(jìn)程??梢詤⒖枷旅鎯蓚€(gè)鏈接了解。
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; }
*博客內(nèi)容為網(wǎng)友個(gè)人發(fā)布,僅代表博主個(gè)人觀點(diǎn),如有侵權(quán)請(qǐng)聯(lián)系工作人員刪除。