The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group


sigwait - wait for queued signals


#include <signal.h>

int sigwait(const sigset_t *set, int *sig);


The sigwait() function selects a pending signal from set, atomically clears it from the system's set of pending signals, and returns that signal number in the location referenced by sig. If prior to the call to sigwait() there are multiple pending instances of a single signal number, it is implementation-dependent whether upon successful return there are any remaining pending signals for that signal number. If the implementation supports queued signals and there are multiple signals queued for the signal number selected, the first such queued signal causes a return from sigwait() and the remainder remain queued. If no signal in set is pending at the time of the call, the thread is suspended until one or more becomes pending. The signals defined by set will been blocked at the time of the call to sigwait(); otherwise the behaviour is undefined. The effect of sigwait() on the signal actions for the signals in set is unspecified.

If more than one thread is using sigwait() to wait for the same signal, no more than one of these threads will return from sigwait() with the signal number. Which thread returns from sigwait() if more than a single thread is waiting is unspecified.

Should any of the multiple pending signals in the range SIGRTMIN to SIGRTMAX be selected, it shall be the lowest numbered one. The selection order between realtime and non-realtime signals, or between multiple pending non-realtime signals, is unspecified.


Upon successful completion, sigwait() stores the signal number of the received signal at the location referenced by sig and returns zero. Otherwise, an error number is returned to indicate the error.


The sigwait() function may fail if:
The set argument contains an invalid or unsupported signal number.








pause(), pthread_sigmask(), sigaction(), <signal.h>, sigpending(), sigsuspend(), sigwaitinfo(), <time.h>.


Derived from the POSIX Realtime Extension (1003.1b-1993/1003.1i-1995) and the POSIX Threads Extension (1003.1c-1995)

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]