SIGSETMASK(3) | Library Functions Manual | SIGSETMASK(3) |
sigsetmask() sets the current signal mask Signals are blocked from delivery if the corresponding bit in mask is a 1; the macro sigmask() is provided to construct the mask for a given signum.
The system quietly disallows SIGKILL or SIGSTOP to be blocked.
int omask; omask = sigblock(sigmask(SIGINT) | sigmask(SIGHUP)); ... sigsetmask(omask & ~(sigmask(SIGINT) | sigmask(SIGHUP)));
Could be converted literally to:
sigset_t set, oset; sigemptyset(&set); sigaddset(&set, SIGINT); sigaddset(&set, SIGHUP); sigprocmask(SIG_BLOCK, &set, &oset); ... sigdelset(&oset, SIGINT); sigdelset(&oset, SIGHUP); sigprocmask(SIG_SETMASK, &oset, NULL);
Another, clearer, alternative is:
sigset_t set; sigemptyset(&set); sigaddset(&set, SIGINT); sigaddset(&set, SIGHUP); sigprocmask(SIG_BLOCK, &set, NULL); ... sigprocmask(SIG_UNBLOCK, &set, NULL);
To completely clear the signal mask using sigsetmask() one can do:
(void) sigsetmask(0);
Which can be expressed via sigprocmask(2) as:
sigset_t eset; sigemptyset(&eset); (void) sigprocmask(SIG_SETMASK, &eset, NULL);
August 10, 2002 | NetBSD 6.1 |