- 在使用 sigaction 函数处理信号时,可以一并设置进程的信号屏蔽字。但是有单独的函数可以用来设置进程的信号屏蔽字:sigprocmask 函数。
- sigprocmask 函数
#include <signal.h>
int sigprocmask(int how, const sigset_t *set, sigset_t *oset);
参数 how 的取值如下:
名称 | 说明 |
---|---|
SIG_BLOCK | 把参数 set 中的信号添加到信号屏蔽字中 |
SIG_SETMASK | 把信号屏蔽字设置为参数 set 中的信号 |
SIG_UNBLOCK | 从信号屏蔽字中删除参数 set 中的信号 |
- 信号集操作函数
#include <signal.h>
int sigemptyset(sigset_t *set); // 初始化信号集为空
int sigaddset(sigset_t *set,