- 论坛徽章:
- 0
|
子进程及时知道父进程已经退出的最简单方案?
原帖由 "gadfly" 发表:
父进程退出的时候,不会自动发送sigterm信号的。
qjlemon的例子是正确的。信号响应函数对子进程同样有效
你这句话只对了一半,信号响应函数对子进程不是全有效的。而在上面的例子里,恰好是无效的。看完下面的就会明白。
Signals set to the default action (SIG_DFL) in the calling
process image are set to the default action in the new pro-
cess image (see signal(3C)).
Signals set to be ignored (SIG_IGN) by the calling process
image are set to be ignored by the new process image. Sig-
nals set to be caught by the calling process image are set
to the default action in the new process image (see
signal(3HEAD)). After a successful call to any of the exec
functions, alternate signal stacks are not preserved and the
SA_ONSTACK flag is cleared for all signals. |
|