sigtimedwait(2P4)
NAME
sigtimedwait, sigwaitrt − wait for signals
SYNOPSIS
#include <sys/siginfo.h>
int sigtimedwait(set, info, timeout)
const sigset_t ∗set;
siginfo_t ∗info;
const struct timespec ∗timeout;
int sigwaitrt(set, info)
const sigset_t ∗set;
siginfo_t ∗info;
DESCRIPTION
The sigtimedwait function selects the pending signal from the set specified by set with the lowest numeric signal value. If no signal in set is pending at the time of the call, the calling process is suspended until one or more signals become pending, or until it is interrupted by a signal, or until the time interval specified in the timespec structure has elapsed. If the timespec structure pointed to by timeout is zero-valued and if none of the signals specified by set are pending, then sigtimedwait returns immediately with an error. If timeout is the NULL pointer, the function will wait indefinitely.
If the info argument is not NULL, 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 is queued to the selected signal, the first such queued value is dequeued and, if the info argument is non-NULL, the value is stored in the si_value member of info. The system resources used to queue the signal are released. If no value is queued, the content of the si_value member is undefined. If no further signals are queued for the selected signal number, the pending indication for that signal is reset.
The sigwaitrt function is equivalent to sigtimedwait with a NULL third argument.
If, while sigtimedwait or sigwaitrt is waiting, a signal occurs which is eligible for delivery (i.e., not blocked by the process signal mask), that signal is handled asynchronously and the wait is interrupted or, if the SA_RESTART flag was used with sigaction(2), restarted.
RETURN VALUE
Upon successful completion (that is, one of the signals specified by set is pending or is generated), sigtimedwait and sigwaitrt return the selected signal number. Otherwise a value of −1 is returned and errno is set to indicate the error.
ERRORS
If any of the following conditions occur, the sigtimedwait and sigwaitrt functions will return −1 and set errno to the corresponding value:
EINTR The wait was interrupted by an unblocked, caught signal.
EFAULT One of the set, info, or timeout arguments pointed to an invalid memory address.
If any of the following conditions occur, the sigtimedwait function will return −1 and set errno to the corresponding value:
EAGAIN No signal specified by set was delivered within the specified timeout period.
If any of the following conditions are detected, the sigtimedwait function will return −1 and set errno to the corresponding value:
EINVAL The timeout argument specified a nanosecond value less than zero or greater than or equal to 1000 million.
FILES
Use of this function requires that the library /usr/lib/libposix4.a be linked with the application.
SEE ALSO
sigaction(2), sigpending(2), sigprocmask(2), sigsuspend(2), signal(5).
NOTES
sigwaitrt is implemented as a macro defined in <signal.h>. A library implementation is visible if that header file is not included or if that macro is undefed after the header file is included.
WARNING
The interfaces to sigtimedwait and sigwaitrt are based on IEEE Draft Standard P1003.4/D12. This is an unapproved draft, subject to change. Use of information contained in this unapproved draft is at your own risk. These interfaces will change to reflect any changes made by future drafts of POSIX 1003.4.
CX/UX Programmer’s Reference Manual