pthread_sigmask(3pthread)


pthread_sigmask -- change or examine the signal mask of a thread

Synopsis

   cc [options] -Kthread file
   

#include <signal.h>

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

Description

pthread_sigmask changes or examines (or both) the calling thread's signal mask according to the way how and set are set.

If there are any pending unblocked signals after the call to pthread_sigmask, at least one of these signals will be delivered before the call to pthread_sigmask returns.

If pthread_sigmask fails, the thread's signal mask is not changed.

It is not possible to block those signals that cannot be ignored (see sigaction(2)); this restriction is silently imposed by the system.

If any of the SIGFPE, SIGILL, SIGSEGV, or SIGBUS signals are generated while they are blocked, the result is undefined, unless the signal was generated by a function capable of sending a signal to a specific process or thread.

The how parameter determines how set is interpreted. how must be one of the following values:


SIG_BLOCK
Add the set of signals denoted by set to the current signal mask.

SIG_UNBLOCK
Remove the set of signals denoted by set from the current signal mask.

SIG_SETMASK
Replace the current signal mask with the set of signals denoted by set.

Note that 0 is not a valid value for how.

The set parameter can be NULL or a pointer to a sigset_t. If set is NULL, the value of how is not significant, and the thread's signal mask will not be changed. Thus, the call can be used to inquire about currently blocked signals.

If set is not NULL, it points to a set of signals to be blocked or unblocked (according to the value of how) in the current thread. set is usually constructed with the routines sigemptyset(3C), sigfillset(3C), sigaddset(3C), sigdelset(3C), and sigismember(3C), which are described on sigsetops(3C).

The oset parameter can be NULL or not NULL. If oset is not NULL, pthread_sigmask stores the value of the previous mask in that location. If oset is not NULL and set is NULL, oset will point to the value of the thread's current signal mask.

Return values

pthread_sigmask returns zero on success. Otherwise, an error number is returned, as described below.

Diagnostics

pthread_sigmask returns the following value if the corresponding condition is detected:

EINVAL
The value of how is not equal to one of the defined values.

Standards Compliance

The Single UNIX Specification, Version 2; The Open Group.

References

Intro(3pthread), kill(2), pthread_kill(3pthread), sigaction(2), signal(5), sigpending(2), sigprocmask(2), sigsend(2), sigsetops(3C), sigsuspend(2), sigwait(2)

Notices

Portability considerations

Threads should use pthread_sigmask rather than sigprocmask(2). In some implementations, sigprocmask can be trapped and behaves identically to pthread_sigmask, but for portability, pthread_sigmask should be used.

Performance considerations

An application running multiplexed (PTHREAD_SCOPE_PROCESS) threads with different signal masks can degrade performance. Therefore, for best performance, all multiplexing threads in a process should use the same signal mask.

Some applications cannot avoid assigning different signal masks to threads; in such cases, performance may be improved by creating those threads as bound (PTHREAD_SCOPE_SYSTEM) threads.

Style considerations

The preferred coding style is to mask all signals and use sigwait synchronously.
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004