sigwaitinfo() — Wait for queued signals

Standards

Standards / Extensions C or C++ Dependencies

Single UNIX Specification, Version 2
Single UNIX Specification, Version 3

both

OS/390 V2R7

Format

#define _XOPEN_SOURCE 500
#include <signal.h>

int sigwaitinfo(const sigset_t *set, siginfo_t *info);

General description

The sigwaitinfo() function selects a pending signal from the sigset_t object (signal set) pointed to by set, automatically clearing it from the system's set of pending signals, and returning that signal number. If there are multiple pending signals, the lowest numbered signal will be selected.

If no signal in the signal set is pending at the time of the call to sigwaitinfo(), the thread is suspended until one or more of the signals specified in the signal set become pending or until it is interrupted by an unblocked, caught signal. The signals defined in the sigset_t object (signal set) pointed to by set may be unblocked during the call to this routine and will be blocked when the thread returns from the call unless some other thread is currently waiting for one of those signals.

If more than one thread is using sigwaitinfo() to wait for the same signal, only one of these threads will return from this routine with the signal number, until a second signal of the same type is received.

The function sigwaitinfo() behaves the same as the sigwait() function if the info argument is NULL. If the info argument is not NULL, then in addition to behaving the same as sigwait(), sigwaitinfo() places the selected signal number in the si_signo member, places the cause of the signal in the si_code member, and, if any value is queued to the selected signal, sigwaitinfo() will place it in the si_value member of info. However, if there is no value queued for the selected signal then the content of si_value is undefined.

Usage notes

The use of the SIGTHSTOP and SIGTHCONT signal is not supported with this function.

Returned value

If successful, sigwaitinfo() returns the signal number.

If unsuccessful, sigwaitinfo() returns -1 and sets errno to one of the following values:

Error Code
Description
EINTR
The wait was interrupted by an unblocked, caught signal. No further waiting will occur for this call. sigwaitinfo() can be reissued to begin waiting again.
EINVAL
set points to a sigset_t that contains a signal number that is either not valid or not supported.

Related information