Sets the current signal mask.
#include <signal.h> int sigprocmask (int how, const sigset_t *set, sigset_t *o_set);
SIG_BLOCK | The resulting set is the union of the current set and the signal set pointed to by the set argument. |
SIG_UNBLOCK | The resulting set is the intersection of the current set and the complement of the signal set pointed to by the set argument. |
SIG_SETMASK | The resulting set is the signal set pointed to by the set argument. |
Typically, use the sigprocmask SIG_BLOCK value to block signals during a critical section of code, then use the sigprocmask SIG_ SETMASK value to restore the mask to the previous value returned by the sigprocmask SIG_BLOCK value.
If there are any unblocked signals pending after the call to the sigprocmask function, at least one of those signals is delivered before the sigprocmask function returns.
You cannot block SIGKILL or SIGSTOP signals with the sigprocmask function. If a program attempts to block one of these signals, the sigprocmask function gives no indication of the error.
The following example shows how to set the signal mask to block only the SIGINT signal from delivery:
#include <signal.h> int return_value; sigset_t newset; . . . sigemptyset(&newset); sigaddset(&newset, SIGINT); return_value = sigprocmask (SIG_SETMASK, &newset, NULL);
0 | Indicates success. |
-1 | Indicates an error. The signal mask
of the process is unchanged. errno is set to one of the following
values:
|