ubuntu下孤儿进程的ppid为何不是1?
来源:互联网 发布:net域名名站 编辑:程序博客网 时间:2024/06/08 14:41
linux下用fork()可以创建一个新进程,如果该进程的父进程先于该进程死亡,该子进程就会变成孤儿进程,被init进程收养,其ppid本应为1,即init进程.
代码如下:
#include<stdio.h>#include<sys/types.h>#include<unistd.h>#include<stdlib.h>int main(void){ pid_t pid; printf("Process Creation Study\n"); pid = fork(); switch(pid) { case 0: while(1) { printf("I'm a child process,my pid is %d,my parent pid id %d\n",getpid(),getppid()); sleep(2); } case -1: perror("Process creation failed\n"); break; default: printf("I'm a Parent process,my pid id %d\n",getpid()); exit(0); } return 0;}
但我在ubuntu下执行时却发现不是init进程,而是/sbin/upstart –user
4 1000 1496 1479 20 0 48360 4944 poll_s Ss ? 0:00 /sbin/upstart --user
其父进程是:lightdm
root 1479 0.0 0.0 230300 6388 ? Sl 08:08 0:00 lightdm --session-child 12 19
百度一下发现这是个桌面软件,那么不在图形界面是不是就被init进程收养了呢?
然后ctrl+alt+F1进入字符界面,再次运行刚才程序,出现了结果,ppid=1.
1 0
- ubuntu下孤儿进程的ppid为何不是1?
- Ubuntu下孤儿进程问题
- 父进程为1号进程(ppid=1)的僵尸进程处理和分析
- ubuntu中孤儿进程的父进程pid并不是1??
- Liunx下的僵死进程和孤儿进程
- linux下的僵尸进程和孤儿进程
- liunx下的僵尸进程和孤儿进程
- 孤儿进程的父进程
- linux下僵尸进程和孤儿进程
- linux下孤儿进程和僵尸进程
- Linux下僵尸进程与孤儿进程
- 孤儿进程组的由来
- Linux的“孤儿进程”的“父进程”
- 僵尸进程和孤儿进程的比较
- 僵尸进程和孤儿进程的区别
- 孤儿进程与僵尸进程的理解
- 孤儿进程和僵尸进程的区别
- 孤儿进程和僵尸进程的区别
- android SpannableString使用详解
- 【Codeforces Round 364 (Div 2)B】【简单讨论】Cells Not Under Attack 行列炮台覆盖不被攻击格子数
- hdu 4520
- iOS开发常用第三方库的整理
- Github计算contributions
- ubuntu下孤儿进程的ppid为何不是1?
- 23种设计模式汇总整理
- android 使用java 代码设置 textview的图片
- R语言 我要如何开始R语言
- home live buy
- Linux冷门却很重要的命令(二)---pgrep
- win7 64位,PowerDesigner中导入MYSQL数据库结构的步骤及问题解决
- Leetcode 2. Add Two Numbers
- Android Studio代码检测和性能分析工具