sigaddset()--Add Signal to Signal Set
Syntax
#include <signal.h> int sigaddset( sigset_t *set, int signo );
Service Program Name: QPOSSRV1
Default Public Authority: *USE
Threadsafe: Yes
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.
Authorities and Locks
None.
Parameters
- *set
- (Input) A pointer to a signal set.
- signo
- (Input) A signal from the list defined in Control Signals Table.
Return Value
0 | sigaddset() successfully added to the signal set. |
-1 | sigaddset() was not successful. The errno variable is set to indicate the error. |
Error Conditions
If sigaddset() is not successful, errno usually indicates the following error. Under some conditions, errno could indicate an error other than that listed here.
- [EINVAL]
-
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.
Related Information
- The <signal.h> file (see Header
Files for UNIX®-Type Functions)
- sigaction()--Examine and Change Signal Action
- sigdelset()--Delete Signal from Signal Set
- sigemptyset()--Initialize and Empty Signal
Set
- sigfillset()--Initialize and Fill Signal Set
- sigismember()--Test for Signal in Signal Set
- sigprocmask()--Examine and Change Blocked
Signals
- sigpending()--Examine Pending Signals
- sigsuspend()--Wait for Signal
- sigtimedwait()--Synchronously Accept a Signal
for Interval of Time
- sigwait()--Synchronously Accept a Signal
- sigwaitinfo()--Synchronously Accept a Signal and Signal Data
Example
The following example adds a signal to a set of signals.
Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.
#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 ); }
Output:
before first kill() catcher() has gained control before second kill() after second kill()
API introduced: V3R6