[問題] fork orphan process

看板LinuxDev作者 (yshihyu)時間7年前 (2017/05/11 22:34), 編輯推噓0(004)
留言4則, 1人參與, 最新討論串1/1
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://www.ptt.cc/bbs/LinuxDev/M.1494513253.A.849.html

05/12 00:37, , 1F
因為 upstart --user 有用 prctl 設定 `subreaper` 的 flag
05/12 00:37, 1F

05/12 00:38, , 2F
簡單來說就是他代替了 init 去接管 orphan
05/12 00:38, 2F

05/12 00:39, , 3F
https://goo.gl/JPWp9E from unix.stackexchange.com
05/12 00:39, 3F

05/12 00:39, , 4F
這篇用 upstart orphan process 可以查到
05/12 00:39, 4F
文章代碼(AID): #1P57PbX9 (LinuxDev)