sigismember()--Test for Signal in Signal Set


Syntax
#include <signal.h>

int sigismember( const sigset_t *set, int signo );


Threadsafe: Yes

The sigismember() 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()).

sigismember() tests whether a signal number specified by signo is a member of a signal set specified by set.

Parameters

*set
(Input) A pointer to a signal set.

signo
(Input) A signal from the list defined in Figure 1-2.

Return Value

1
The specified signal is in the specified signal set.
0
The specified signal is not in the specified signal set.
-1
An error occurred. The errno variable is set to indicate the error.

Error Conditions

If sigismember() is not successful, errno usually indicates the following error. Under some conditions, errno could indicate an error other than that listed here.

[ERROR_INVALID_PARAMETER]
An invalid parameter was found.

A parameter passed to this function is not valid.

The value of signo is not within the range of valid signals or specifies a signal that is not supported.

Related Information

Example

The following example uses the sigismember() function to test for the presence of signals in a signal set:


#include <stdio.h>
#include <signal.h>

void check( sigset_t set, int signo, char *signame ) {

    printf( "%s is ", signame );
    if( !sigismember( &set, signo ) )
      printf( "not ");
    printf( "in the set" );
}

int main( int argc, char *argv[] ) {

    sigset_t sigset;

    sigemptyset( &sigset );

    sigaddset( &sigset, SIGUSR1 );
    sigaddset( &sigset, SIGKILL );
    sigaddset( &sigset, SIGCHLD );

    check( sigset, SIGUSR1, "SIGUSR1" );
    check( sigset, SIGUSR2, "SIGUSR2" );
    check( sigset, SIGCHLD, "SIGCHLD" );
    check( sigset, SIGFPE,  "SIGFPE" );
    check( sigset, SIGKILL, "SIGKILL" );

    return( 0 );
}

Output:

    SIGUSR1 is in the set
    SIGUSR2 is not in the set
    SIGCHLD is in the set
    SIGFPE is not in the set
    SIGKILL is in the set


Top | Signal APIs | UNIX-Type APIs
APIs by category

[Information Center Home Page | Feedback ] [Legal | AS/400 Glossary]