当前位置: 技术问答>linux和unix
关于系统信号处理函数signal()的疑问.
来源: 互联网 发布时间:2015-01-23
本文导语: 我看书中给出的signal()函数代码只是调用了sigaction()一次,并没有循环,那它如何做到"一经启动,长期有效"呢?书中的服务器端源码只在调用listen()之后调用了一次signal(),可是却能处理N个子进程的SIGCHLD信号,何解?! ...
我看书中给出的signal()函数代码只是调用了sigaction()一次,并没有循环,那它如何做到"一经启动,长期有效"呢?书中的服务器端源码只在调用listen()之后调用了一次signal(),可是却能处理N个子进程的SIGCHLD信号,何解?!
|
if you call signal(), you need to call signal() again in your signal handler to keep your handler in effect (unless your system conforms to BSD semantics, see man page of signal.
However, if you call sigaction(), once a signal handler is installed, it normally remains installed until another sigaction() call is made, or an execve() is performed.
However, if you call sigaction(), once a signal handler is installed, it normally remains installed until another sigaction() call is made, or an execve() is performed.