中国城乡建设部网站房贴文件,免费ppt模版网站,百度站长怎么做网站维护,申请付费网站孤儿进程#xff1a;父进程先于子进程结束#xff0c;则子进程成为孤儿进程#xff0c;子进程的父进程成为init进程#xff0c;称为init进程领养孤儿进程。 /***
orphan.c
***/
#include stdio.h
#include unistd.h
#include sys/wait.hint main(v… 孤儿进程父进程先于子进程结束则子进程成为孤儿进程子进程的父进程成为init进程称为init进程领养孤儿进程。 /***
orphan.c
***/
#include stdio.h
#include unistd.h
#include sys/wait.hint main(void)
{pid_t pid;pid fork();if (pid 0) {while (1) {printf(I am child, my parent pid %d\n, getppid());sleep(1);}} else if (pid 0) {printf(I am parent, my pid is %d\n, getpid());sleep(9);printf(------------parent going to die------------\n);} else {perror(fork);return 1;}return 0;
} 僵尸进程 进程终止父进程尚未回收子进程残留资源PCB存放于内核中变为僵尸进程。 /***
zoom.c
***/
#include stdio.h
#include stdlib.h
#include unistd.h
#include sys/wait.hint main(void)
{pid_t pid, wpid;pid fork();if (pid 0) {printf(---child, my parent %d, going to sleep 10s\n, getppid());sleep(10);printf(-------------child die--------------\n);} else if (pid 0) {while (1) {printf(I am parent, pid %d, myson %d\n, getpid(), pid);sleep(1);}} else {perror(fork);return 1;}return 0;
} 转载于:https://www.cnblogs.com/wanghao-boke/p/11311820.html