Sets the signal mask of a thread.
Threads Library (libpthreads.a)
#include <pthread.h> #include <signal.h>
int sigthreadmask( how, set, old_set)
int how;
const sigset_t *set;
sigset_t *old_set;
The sigthreadmask subroutine is used to examine or change the signal mask of the calling thread. The sigprocmask subroutine must not be used in a multi-threaded process.
Typically, the sigthreadmask(SIG_BLOCK) subroutine is used to block signals during a critical section of code. The sigthreadmask(SIG_SETMASK) subroutine is then used to restore the mask to the previous value returned by the sigthreadmask(SIG_BLOCK) subroutine.
If there are any pending unblocked signals after the call to the sigthreadmask subroutine, at least one of those signals will be delivered before the sigthreadmask subroutine returns.
The sigthreadmask subroutine does not allow the SIGKILL or SIGSTOP signal to be blocked. If a program attempts to block either signal, the sigthreadmask subroutine gives no indication of the error.
Upon completion, a value of 0 is returned. If the sigthreadmask 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 sigthreadmask subroutine is unsuccessful if the following is true:
To set the signal mask to block only the SIGINT signal from delivery, enter:
#include <pthread.h> #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 = sigthreadmask(SIG_SETMASK, newset_p, NULL);
The kill or killpg subroutine, pthread_kill subroutine, sigaction, sigvec, or signal (sigaction, sigvec, or signal Subroutine) subroutine, sigpause (sigsuspend or sigpause Subroutine) subroutine, sigpending (sigpending Subroutine) subroutine, sigwait (sigwait Subroutine) subroutine, sigsuspend (sigsuspend or sigpause Subroutine) subroutine.
Signal Management in AIX 5L Version 5.2 General Programming Concepts: Writing and Debugging Programs.