wait for a signal to be posted
int sigwait(sigset_t *set);
This function atomically chooses and clears a pending
signal from set and returns the number of the signal chosen.
If no signal in set is pending at the time of the call,
the calling function shall be suspended until one or more signals become
This suspension is indefinite in extent.
The set of signals remains blocked after return.
An application should not mix use of sigwait and
sigaction for a given signal number
because the results may be unpredictable.
Upon successful completion,
sigwait returns the signal number of the received signal.
Otherwise, a negative value is returned and errno is
set to indicate the error.
If any of the following conditions occurs, sigwait
returns a negative value and sets errno to the corresponding
set contains an invalid or unsupported signal number
set points to an illegal address.
Considerations for threads programming
The sigwait system call allows a multithreaded application
to use a synchronous organization for signal handling.
The semantics of sigwait make it ideal for a thread that will
be dedicated to handling certain signal types for a process.
The functionality that might have been placed in a separate handler
function could be placed after the return from sigwait
to be executed once a signal arrives.
Once handling is complete,
the thread could call sigwait again to block itself until
arrival of the next signal.
To be sure that signals are delivered to the intended thread:
All threads in the process
(including the thread that will be using sigwait)
should mask the relevant signal types.
Only the intended thread should use sigwait.
No thread should define a handler function.
for further details.
Code to handle a signal type on return from sigwait
is not considered a handler in the containing process' disposition for
that signal type.
It is important that signal types handled by a thread using
be included in the signal mask of every thread,
otherwise, the default response for the process will be triggered.
Even the thread calling sigwait should mask that signal type
because a signal of that type may arrive while the thread is
between calls to
While one thread is blocked, siblings might still be executing.
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 - 01 June 2005