The sigwait function suspends the calling thread until at least one of the signals in the set argument is in the caller's set of pending signals. When this happens, one of those signals is automatically selected and removed from the set of pending signals. The signal number identifying that signal is then returned in the location referenced by sig. The effect is unspecified if any signals in the set argument are not blocked when the sigwait function is called. The set argument is created using the set manipulation functions sigemptyset, sigfillset, sigaddset, and sigdelset. If, while the sigwait function is waiting, a signal occurs that is eligible for delivery (that is, not blocked by the signal mask), that signal is handled asynchronously and the wait is interrupted. See also sigtimedwait and sigwaitinfo. See the "Error and Signal Handling" chapter of the VSI C RTL Reference Manual for more information on signal handling.