我正在学习 Unix 中的信号处理,很难理解 sigprocmask()
中的 SIG_SETMASK
和 o_set
以及它们的作用做什么?
我知道 set
包含要阻止或取消阻止的信号列表,SIG_BLOCK
阻止列表中的信号,SIG_UNBLOCK
取消阻止它们.
sigprocmask(SIG_SETMASK,&set,& o_set);
最佳答案
Linux manpage很好地解释了这一点。
如果该参数为非空,则信号掩码的先前值存储在最后一个参数(旧集)中。
SIG_SETMASK
设置当前信号集。我不确定还有什么要说的 - SIG_BLOCK
和 SIG_UNBLOCK
将当前信号掩码与第二个参数相结合,SIG_SETMASK
集它与当前值无关。
POSIX解释如下:
SIG_BLOCK
The resulting set shall be the union of the current set and the signal set pointed to by set.SIG_SETMASK
The resulting set shall be the signal set pointed to by set.
SIG_UNBLOCK
The resulting set shall be the intersection of the current set and the complement of the signal set pointed to by set.
关于c - Unix 中的信号处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14183718/