Multithreaded Programming Guide

Exit Print View

Updated: July 2014
 
 

Accessing the Signal Mask of the Calling Thread

Use pthread_sigmask(3C) to change or examine the signal mask of the calling thread.

pthread_sigmask Syntax

int pthread_sigmask(int how, const sigset_t *new, sigset_t *old);
#include <pthread.h>
#include <signal.h>

int ret;
sigset_t old, new;

ret = pthread_sigmask(SIG_SETMASK, &new, &old); /* set new mask */
ret = pthread_sigmask(SIG_BLOCK, &new, &old); /* blocking mask */
ret = pthread_sigmask(SIG_UNBLOCK, &new, &old); /* unblocking */

how determines how the signal set is changed. how can have one of the following values:

  • SIG_BLOCK. Add new to the current signal mask, where new indicates the set of signals to block.

  • SIG_UNBLOCK. Delete new from the current signal mask, where new indicates the set of signals to unblock.

  • SIG_SETMASK . Replace the current signal mask with new, where new indicates the new signal mask.

When the value of new is NULL, the value of how is not significant. The signal mask of the thread is unchanged. To inquire about currently blocked signals, assign a NULL value to the new argument.

The old variable points to the space where the previous signal mask is stored, unless old is NULL.

pthread_sigmask Return Values

pthread_sigmask() returns zero when the call completes successfully. Any other return value indicates that an error occurred. When the following condition occurs, pthread_sigmask() fails and returns the corresponding value.

EINVAL

Description: The value of how is not defined and old is NULL.