作者yshihyu (yshihyu)
看板LinuxDev
标题[问题] fork orphan process
时间Thu May 11 22:34:07 2017
http://www.cnblogs.com/Anker/p/3271773.html
我书上看到跟网路上看到范例都类似
在子行程sleep 变成 孤儿行程, 之後由 init pid = 1 去接管
https://gist.github.com/anonymous/f17087ea7aeaa7077ebac5ebd4768528 // 程式码
可是输出结果子行程sleep 5秒後是父行程不是 init
I am father process.
I am the child process.
pid: 23665 ppid:23664
I will sleep five seconds.
father process is exited.
pid: 23665 ppid:3829 // 这边是 3829 不是 init 的 1
child process is exited.
後来我查一下 ps aux , 3829 是 /sbin/upstart --user 请问为什麽不是 init
3829 0.0 0.0 46924 4876 ? Ss 21:19 0:00 /sbin/upstart --user
知道的朋友可以跟我说一下原因嘛?
谢谢
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 175.181.186.6
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/LinuxDev/M.1494513253.A.849.html
1F:→ CP64: 因为 upstart --user 有用 prctl 设定 `subreaper` 的 flag 05/12 00:37
2F:→ CP64: 简单来说就是他代替了 init 去接管 orphan 05/12 00:38
4F:→ CP64: 这篇用 upstart orphan process 可以查到 05/12 00:39