#include <signal.h> int sigaddset( sigset_t *set, int signo );
The sigaddset() function is part of a family of functions that manipulate signal sets. Signal sets are data objects that let a thread keep track of groups of signals. For example, a thread might create a signal set to record which signals it is blocking, and another signal set to record which signals are pending. Signal sets are used to manipulate groups of signals used by other functions (such as sigprocmask()) or to examine signal sets returned by other functions (such as sigpending()).
sigaddset() adds a signal to the set of signals already recorded in set.
None.
0 | sigaddset() successfully added to the signal set. |
-1 | sigaddset() was not successful. The errno variable is set to indicate the error. |
If sigaddset() is not successful, errno usually indicates the following error. Under some conditions, errno could indicate an error other than that listed here.
The value specified for the argument is not correct.
A function was passed incorrect argument values, or an operation was attempted on an object and the operation specified is not supported for that type of object.
An argument value is not valid, out of range, or NULL.
The value of signo is not within the range of valid signals or specifies a signal that is not supported.
See Code disclaimer information for information pertaining to code examples.
The following example adds a signal to a set of signals:
#include <stdio.h> #include <unistd.h> #include <signal.h> void catcher( int sig ) { printf( "catcher() has gained control\n" ); } int main( int argc, char *argv[] ) { struct sigaction sigact; sigset_t sigset; sigemptyset( &sigact.sa_mask ); sigact.sa_flags = 0; sigact.sa_handler = catcher; sigaction( SIGUSR1, &sigact, NULL ); printf( "before first kill()\n" ); kill( getpid(), SIGUSR1 ); /* * Blocking SIGUSR1 signals prevents the signals * from being delivered until they are unblocked, * so the catcher will not gain control. */ sigemptyset( &sigset ); sigaddset( &sigset, SIGUSR1 ); sigprocmask( SIG_SETMASK, &sigset, NULL ); printf( "before second kill()\n" ); kill( getpid(), SIGUSR1 ); printf( "after second kill()\n" ); return( 0 ); }
before first kill() catcher() has gained control before second kill() after second kill()
Top | UNIX-Type APIs | APIs by category |