#include <signal.h>
int sigwaitinfo(const sigset_t *set, siginfo_t *info);
int sigtimedwait(const sigset_t *set, siginfo_t *info, const struct timespec *timeout);
typedef struct siginfo {
int si_signo; /* signal from signal.h */
int si_code; /* code from above */
...
int si_value;
...
} siginfo_t;
struct timespec {
time_t tv_sec; /* seconds */
long tv_nsec; /* and nanoseconds */
};
If no signal in set is pending at the time of the call, sigwaitinfo() suspends the calling process until one or more signals in set become pending or until it is interrupted by an unblocked, caught signal. sigtimedwait(), on the other hand, suspends itself for the time interval specified in the timespec structure referenced by timeout. 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 the error EAGAIN.
If, while sigwaitinfo() or sigtimedwait() 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.
If info is non-NULL , the selected signal number is stored in si_signo, and the cause of the signal is stored in the si_code. If any value is queued to the selected signal, the first such queued value is dequeued and, if info is non-NULL , the value is stored in the si_value member of info. The system resource used to queue the signal is released and made available to queue other signals.
If the value of the si_code member is SI_NOINFO, only the si_signo member of siginfo_t is meaningful, and the value of all other members is unspecified.
If no further signals are queued for the selected signal, the pending indication for that signal is reset.
The following errors relate to only sigtimedwait():