DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

pthread_sigmask(PTHREAD)


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(S)); 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(S), sigfillset(S), sigaddset(S), sigdelset(S), and sigismember(S), which are described on sigsetops(S).

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(PTHREAD), kill(S), pthread_kill(PTHREAD), sigaction(S), signal(M), sigpending(S), sigprocmask(S), sigsend(S), sigsetops(S), sigsuspend(S), sigwait(S)

Notices

Portability considerations

Threads should use pthread_sigmask rather than sigprocmask(S). 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.
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 - 01 June 2005