sigismember() — Test if a signal is in a signal mask
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
POSIX.1 |
both |
Format
#define _POSIX_SOURCE
#include <signal.h>
int sigismember(const sigset_t *set, int signal);
General description
Tests whether a specified signal number signal is a member of a signal set set.
sigismember() is part of a family of functions that manipulate signal sets. Signal sets are data objects that let a process keep track of groups of signals. For example, a process can create one 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()).
Applications should call either sigemptyset() or sigfillset() at least once for each object of type sigset_t prior to any other use of that object. If such an object is not initialized in this way, but is nonetheless supplied as an argument to any of pthread_sigmask(), sigaction(), sigaddset(), sigdelset(), sigismember(), sigpending(), sigprocmask(), sigsuspend(), sigtimedwait(), sigwait(), or sigwaitinfo(), the results are undefined.
Usage note
The use of the SIGTHSTOP and SIGTHCONT signal is not supported with this function.
Returned value
sigismember() returns 1 if signal is in set, and it returns 0 if it is not.
- Error Code
- Description
- EINVAL
- The value of signal is not one of the supported signals.
Example
/* CELEBS19
This example tests signals.
*/
#define _POSIX_SOURCE
#include <stdio.h>
#include <signal.h>
void check(sigset_t set, int signum, char *signame) {
printf("%-8s is ", signame);
if (!sigismember(&set, signum))
printf("not ");
puts("in the set");
}
main() {
sigset_t sigset;
sigemptyset(&sigset);
sigaddset(&sigset, SIGUSR1);
sigaddset(&sigset, SIGKILL);
sigaddset(&sigset, SIGCHLD);
check(sigset, SIGUSR1, "SIGUSR1");
check(sigset, SIGUSR2, "SIGUSR2");
check(sigset, SIGFPE, "SIGFPE");
check(sigset, SIGKILL, "SIGKILL");
}
SIGUSR1 is in the set
SIGUSR2 is not in the set
SIGFPE is not in the set
SIGKILL is in the set
Related information
- signal.h
- sigaction() — Examine or change a signal action
- sigaddset() — Add a signal to the signal mask
- sigdelset() — Delete a signal from the signal mask
- sigemptyset() — Initialize a signal mask to exclude all signals
- sigfillset() — Initialize a signal mask to include all signals
- sighold() — Add a signal to a thread
- signal() — Handle interrupts
- sigpause() — Unblock a signal and wait for a signal
- sigpending() — Examine pending signals
- sigprocmask() — Examine or change a thread
- sigset() — Change a signal action or a thread
- sigsuspend() — Change mask and suspend the thread