鍍金池/ 問答/C  Linux/ 僵死進(jìn)程被init接受后會如何表現(xiàn)?

僵死進(jìn)程被init接受后會如何表現(xiàn)?

設(shè)想如下情況:現(xiàn)有進(jìn)程A,fork產(chǎn)生子進(jìn)程B,子進(jìn)程B調(diào)用exit(0),這時B會向父進(jìn)程A發(fā)送SIGCHLD信號,父進(jìn)程A選擇忽略掉這個信號,進(jìn)程B變?yōu)榻┧肋M(jìn)程。

那么如果此時A正常結(jié)束了,B就應(yīng)該會轉(zhuǎn)交成為init進(jìn)程的子進(jìn)程,此時會發(fā)生什么?B會不會重新發(fā)送SIGCHLD信號給init呢?如果不會的話,B最后將如何結(jié)束?

回答
編輯回答
筱饞貓

B 不會再發(fā)送任何信號,這種僵尸進(jìn)程最終被 init 進(jìn)程(pid=1)自動回收。

請參考

When a process loses its parent, init becomes its new parent. init periodically executes the wait system call to reap any zombies with init as parent.

https://en.wikipedia.org/wiki...

2018年1月2日 10:27