Signal-handling routines normally execute with the signal that caused their invocation to be ``blocked'', but other signals may yet occur. Mechanisms are provided whereby ``critical-sections'' of code may protect themselves against the occurrence of specified signals.
To block a section of code against one or more signals, a call to sigprocmask may be used to add a set of signals to the existing mask and return the old mask:
sigprocmask ( SIG_BLOCK , sigset_t *new_mask , sigset_t *old_mask )The old mask can then be restored later with sigprocmask, as follows:
sigprocmask ( SIG_UNBLOCK , sigset_t *new_mask , sigset_t *old_mask )The function sigprocmask can be used to read the current mask without changing it by specifying a null-pointer as its second argument.
It is possible to check conditions with some signals blocked and then to pause waiting for a signal and restoring the mask, by using:
sigsuspend ( sigset_t *sig_mask )