gtpc2m6v | C/C++ Language Support User's Guide |
This function replaces the current signal mask for the calling process with a new signal set and then suspends the calling process until a signal is delivered.
Format
#include <signal.h> int sigsuspend(sigset_t *set);
Normal Return
The purpose of the sigsuspend function is to suspend the calling process until a signal causes control to be returned. When a signal is received while the calling process is suspended and the associated signal handler returns control to the calling process, the sigsuspend function returns a value of -1 and sets errno to EINTR, which indicates that sigsuspend function processing was interrupted by a signal.
Error Return
None.
Programming Considerations
Examples
The following example suspends processing of the current process until a signal arrives.
#include <signal.h>
·
·
·
{ sigset_t new_mask; /* initialize the new signal mask */ sigemptyset(&new_mask); sigaddset(&new_mask,SIGCHLD); /* wait for any signal except SIGCHLD */ sigsuspend(&new_mask); /* we only expect to get control here if sigsuspend was */ /* interrupted by a signal for which a signal handler */ /* was called and only if that signal handler returned */
·
·
·
/* initialize the new signal mask */ sigfillset(&new_mask); sigdelset(&new_mask,SIGUSR1); /* wait for ONLY a SIGUSR1 signal */ sigsuspend(&new_mask); /* we only expect to get control here if sigsuspend was */ /* interrupted by a signal for which a signal handler */ /* was called and only if that signal handler returned */
·
·
·
}
Related Information