Atomically changes the set of blocked signals and waits for a signal. Format #include <signal.h> int sigsuspend (const sigset_t *signal_mask);
1 – Argument
signal_mask A pointer to a set of signals.
2 – Description
The sigsuspend function replaces the signal mask of the process with the set of signals pointed to by the signal_mask argument. Then it suspends execution of the process until delivery of a signal whose action is either to execute a signal catching function or to terminate the process. You cannot block the SIGKILL or SIGSTOP signals with the sigsuspend function. If a program attempts to block either of these signals, sigsuspend gives no indication of the error. 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 intercepted 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.