Linux系统编程----孤儿进程
2016-09-30 09:30
330 查看
什么是孤儿进程?
孤儿进程, 指在父进程退出后,而子进程还在运行,
这个子进程就成了孤儿进程,这时由init进程(pid=1)接管
来看看例子:
孤儿进程, 指在父进程退出后,而子进程还在运行,
这个子进程就成了孤儿进程,这时由init进程(pid=1)接管
来看看例子:
#include <stdio.h> #include <unistd.h> int main(void) { pid_t pid ; //父进程先结束,子进程还在运行 //如果父进程结束,则子进程的父亲为init //孤儿进程由进程他的祖先收留 pid = fork(); if(0 == pid) { printf("first child pid:%d ppid:%d \n" , getpid() , getppid()); sleep(2); printf("second child pid:%d ppid:%d \n" , getpid() , getppid()); while(1) sleep(1); return 0 ; } sleep(1); printf("parent pid:%d ppid:%d \n" , getpid() , getppid()); printf("I am die ... \n"); return 0 ; }
相关文章推荐
- Linux系统编程----孤儿进程
- linux系统编程之进程(三):进程复制fork,孤儿进程,僵尸进程
- Linux系统编程----孤儿进程
- linux系统编程之进程(三):进程复制fork,孤儿进程,僵尸进程
- 【Linux系统编程】特殊进程之孤儿进程
- 九、Linux系统编程-进程(二)fork系统调用、复制进程映像、写时复制、孤儿进程和僵尸进程
- linux系统编程之进程(三):进程复制fork,孤儿进程,僵尸进程
- linux系统编程之进程(三):进程复制fork,孤儿进程,僵尸进程
- 进程返回linux系统编程之管道(二):管道读写规则和Pipe Capacity、PIPE_BUF
- Linux下的C编程实战(开发平台搭建,文件系统编程,进程控制与进程通信编程,“线程”控制与“线程”通信编程,驱动程序设计,专家问答)
- LINUX中什么是僵尸进程和孤儿进程,它们是否消耗系统资源?
- linux系统编程之进程(四):进程退出exit,_exit区别即atexit函数
- linux系统编程之进程(五):exec系列函数(execl,execlp,execle,execv,execvp)使用
- Linux系统进程控制编程---system系统调用
- Linux系统进程控制编程--wait函数的使用
- linux系统编程之进程(四):进程退出exit,_exit区别即atexit函数
- linux系统编程之进程(八):守护进程详解及创建,daemon()使用
- Linux系统进程控制编程(三)——exec函数族的使用
- linux系统编程之进程(二):进程生命周期与PCB(进程控制块)
- Linux系统进程控制编程(五)——popen函数调用