Sets the current signal mask.
Standard C Library (libc.a)
#include <signal.h>
int sigprocmask ( How, Set, OSet)
int How;
const sigset_t *Set;
sigset *OSet;
int sigsetmask ( SignalMask)
int SignalMask;
int sigblock (SignalMask)
int SignalMask;
The sigprocmask subroutine is used to examine or change the signal mask of the calling thread.
The subroutine is used to examine or change the signal mask of the calling process.
Typically, you should use the sigprocmask(SIG_BLOCK) subroutine to block signals during a critical section of code. Then use the sigprocmask(SIG_SETMASK) subroutine to restore the mask to the previous value returned by the sigprocmask(SIG_BLOCK) subroutine.
If there are any pending unblocked signals after the call to the sigprocmask subroutine, at least one of those signals will be delivered before the sigprocmask subroutine returns.
The sigprocmask subroutine does not allow the SIGKILL or SIGSTOP signal to be blocked. If a program attempts to block either signal, the sigprocmask subroutine gives no indication of the error.
The sigsetmask subroutine allows changing the process signal mask for signal values 1 to 31. This same function can be accomplished for all values with the sigprocmask(SIG_SETMASK) subroutine. The signal of value i will be blocked if the ith bit of SignalMask parameter is set.
Upon successful completion, the sigsetmask subroutine returns the value of the previous signal mask. If the subroutine fails, a value of -1 is returned and the errno global variable is set to indicate the error as in the sigprocmask subroutine.
The sigblock subroutine allows signals with values 1 to 31 to be logically ORed into the current process signal mask. This same function can be accomplished for all values with the sigprocmask(SIG_BLOCK) subroutine. The signal of value i will be blocked, in addition to those currently blocked, if the i-th bit of the SignalMask parameter is set.
It is not possible to block a SIGKILL or SIGSTOP signal using the sigblock or sigsetmask subroutine. This restriction is silently imposed by the system without causing an error to be indicated.
Upon successful completion, the sigblock subroutine returns the value of the previous signal mask. If the subroutine fails, a value of -1 is returned and the errno global variable is set to indicate the error as in the sigprocmask subroutine.
Upon completion, a value of 0 is returned. If the sigprocmask subroutine fails, the signal mask of the process is unchanged, a value of -1 is returned, and the global variable errno is set to indicate the error.
The sigprocmask subroutine is unsuccessful if the following is true:
To set the signal mask to block only the SIGINT signal from delivery, enter:
#include <signal.h> int return_value; sigset_t newset; sigset_t *newset_p; . . . newset_p = &newset; sigemptyset(newset_p); sigaddset(newset_p, SIGINT); return_value = sigprocmask (SIG_SETMASK, newset_p, NULL);
The kill or killpg subroutine, sigaction, sigvec, or signal (sigaction, sigvec, or signal Subroutine) subroutine, sigaddset, sigdelset, sigemptyset, sigfillset, sigismember (sigemptyset, sigfillset, sigaddset, sigdelset, or sigismember Subroutine) subroutine, sigpause (sigsuspend or sigpause Subroutine) subroutine, sigpending (sigpending Subroutine) subroutine, sigsuspend (sigsuspend or sigpause Subroutine) subroutine.