Atomically changes the set of blocked signals and waits for a signal.
#include <signal.h> int sigsuspend (const sigset_t *signal_mask);
If delivery of a signal causes the process to terminate, sigsuspend does not return. If delivery of a signal causes a signal catching function to execute, sigsuspend returns after the signal catching function returns, with the signal mask restored to the set that existed prior to the call to sigsuspend.
The sigsuspend function sets the signal mask and waits for an unblocked signal as one atomic operation. This means that signals cannot occur between the operations of setting the mask and waiting for a signal. If a program invokes sigprocmask SIG_SETMASK and sigsuspend separately, a signal that occurs between these functions is often not noticed by sigsuspend.
In normal usage, a signal is blocked by using the sigprocmask function at the beginning of a critical section. The process then determines whether there is work for it to do. If there is no work, the process waits for work by calling sigsuspend with the mask previously returned by sigprocmask.
If a signal is caught by the calling process and control is returned from the signal handler, the calling process resumes execution after sigsuspend, which always returns a value of -1 and sets errno to EINTR.
See also sigpause, and sigprocmask in this section.