Updated: October 26, 2022

Modify or examine a thread's signal-blocked mask


#include <signal.h>

int pthread_sigmask( int how,
                     const sigset_t* set,
                     sigset_t* oset );


How you want to change the signal mask; one of:
  • SIG_BLOCK — make the resulting signal mask the union of the current signal mask and the signal set set.
  • SIG_UNBLOCK — make the resulting signal mask the intersection of the current signal mask and the complement of the signal set set.
  • SIG_SETMASK — make the resulting signal mask the signal set set.

This argument is ignored if set is NULL.

NULL, or a pointer to a sigset_t object that specifies the signals that you want to affect in the mask.
NULL, or a pointer to a sigset_t object where the function can store the thread's old signal mask.

You can use various combinations of set and oset to query or change (or both) the signal-blocked mask for a signal.



Use the -l c option to qcc to link against this library. This library is usually included automatically.


The pthread_sigmask() function is used to examine or change (or both) the calling thread's signal mask. If set is non-NULL, the thread's signal mask is set to set. If oset is non-NULL, the thread's old signal mask is returned in oset.

You can't block the SIGKILL and SIGSTOP signals.

The signals SIGSEGV, SIGBUS, SIGILL, and SIGFPE are used by the kernel to indicate to a process that a fault has occurred, and by default will terminate the process. Any such signal delivered by the kernel is a synchronous signal. This means that blocking it does not prevent process termination when the fault is delivered, and any installed signal handlers are skipped. Conversely, if any of these signals is delivered from another user-mode process, via kill(), raise(), pthread_kill(), sigqueue() or SignalKill(), it is an asynchronous signal and is subjected to blocking.


Invalid how parameter.


POSIX 1003.1

Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes