精華區beta Programming 關於我們 聯絡資訊
※ 引述《tinlans.bbs@whshs.cs.nccu.edu.tw (汀)》之銘言: > 其實看到 pid 是 1 的時候就要有感覺了, > 書上應該有說過 parent 要是結束而 child 沒結束的話, > child 會被 init 認養這件事吧。 > 當你的 child 執行到 getppid() 時, > 你的 parent 已經結束了, > 就會發生這種現象, > 不過這也屬於正常現象, > 不能稱之為不 work。 是阿,parent process 先結束了,child 的 parent 就變成 init 了, getppid() 說 parent pid 是 1 沒有什麼不對, 因為現在 init 的確就是 child 的 parent 壓。 minhong 先生如果要確保 getppid() 是原本的 parent, 要在 parent 的地方 sleep 一段時間,確保 parent 比 child 晚結束壓, 或是 parent 要 wait child。 -- 幸福,當我滿頭白髮時,依然能夠與妳手牽著手攸然散步。 -- ※ Origin: SayYA 資訊站 <bbs.sayya.org> ◆ Modify: 06/10/22 0:44:26 <218-162-48-157.dynamic.hinet.net>