SIGWAIT(3) SIGWAIT(3)
sigwait, sigwaitinfo, sigtimedwait - wait for queued signals (POSIX)
#include <signal.h>
#include <sys/timers.h>
int sigwait(const sigset_t *set, int *sig);
int sigwaitinfo(const sigset_t *set, siginfo_t *value);
int sigtimedwait(const sigset_t *set, siginfo_t *value, timespec_t *timeout);
The sigwait() function selects a pending signal from set and returns it
in the storage pointed to by sig. If multiple signals from set are
pending, then the one with the lowest numerical value is selected. If no
signals in set are pending then the call will block until one becomes
pending, The signals defined by set must be blocked at the time of the
call to sigwait() in order to avoid conflicts with installed signal
handlers. If the signals in set are not blocked then the system will
either deliver the signal asynchronously, or sigwait() will return with
the signal. Users are advised to always block signals in set to get
predictable results.
The sigwaitinfo() call behaves the same as the sigwait() call if the
value argument is NULL. If the value argument is non-NULL, the
sigwaitinfo() function behaves the same as sigwait() except the selected
signal number is stored in the si_signo member, and the cause of the
signal is stored in the si_code member. If any value was queued to the
selected signal, the first such queued value is dequeued and the value is
stored in the si_value member of value. The system resource used to queue
the signal shall be released and made available to queue other signals.
If no value is queued, the content of the si_value member is undefined.
If no further signals are queued for the selected signal, the pending
indication for that signal shall be reset.
The function sigtimedwait() behaves the same as sigwaitinfo() except that
if none of the signals specified by set are pending, sigtimedwait() shall
wait for the time interval specified in the timespec structure pointed to
by timeout. If the timespec structure pointed to by timeout is zerovalued
and if none of the signals specified by set are pending, then
sigtimedwait() shall return immediately with an error. If timeout is the
NULL pointer, the behavior is the same as sigwaitinfo()
If any realtime signals (those in the range SIGRTMIN to SIGRTMAX) are
pending, the lowest numbered signal shall be returned. The order in
which realtime and nonrealtime signals are returned is nondeterministic.
The order in which multiple nonrealtime signals are returned is also
nondeterministic.
Page 1
SIGWAIT(3) SIGWAIT(3)
SEE ALSO
kill(2), sigaction(2), sigqueue(3), signal(5), pthread_sigmask(3P).
Upon successful completion, sigwait() returns a 0. Otherwise, it returns
an error number to indicate the error.
Upon successful completion, sigwaitinfo() and sigtimedwait() return the
selected signal number. Otherwise, they return a -1 and set errno to
indicate the error number.
If any of the conditions below occur, the error number will take on the
corresponding value:
[EINTR] The wait was interrupted by an unblocked, caught signal.
If any of the following conditions occur, the sigwait() function shall
return the corresponding value:
[EINVAL] The set argument contains an invalid or unsupported signal
number.
If any of the following conditions occur, the sigtimedwait() function
shall return -1 and set errno to the corresponding value:
[EAGAIN] No signal specified by set was delivered within the
specified timeout period.
[EINVAL] The timeout argument specified a tv_nsec value less than
zero or greater than or equal to 1 billion.
The POSIX and System V signal facilities have different semantics. Using
both facilities in the same program is strongly discouraged and will
result in unpredictable behavior.
PPPPaaaaggggeeee 2222 [ Back ]
|