Standards / Extensions | C or C++ | Dependencies |
---|---|---|
POSIX.1 |
both |
#define _POSIX_SOURCE
#include <signal.h>
int sigdelset(sigset_t *set, int signal);
Removes the specified signal from the list of signals recorded in set.
The sigdelset() function 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. In general, 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.
The use of the SIGTHSTOP and SIGTHCONT signal is not supported with this function.
If the signal is successfully deleted from the signal set, sigdelset() returns 0.
If signal is not supported, sigdelset() returns -1 and sets errno to EINVAL.
⁄* CELEBS16
This example deletes specific signals.
*⁄
#define _POSIX_SOURCE
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
void catcher(int signum) {
puts("catcher() has gained control");
}
main() {
struct sigaction sact;
sigset_t sigset;
sigemptyset(&sact.sa_mask);
sact.sa_flags = 0;
sact.sa_handler = catcher;
sigaction(SIGUSR1, &sact, NULL);
sigfillset(&sigset);
sigprocmask(SIG_SETMASK, &sigset, NULL);
puts("before kill()");
kill(getpid(), SIGUSR1);
puts("before unblocking SIGUSR1");
sigdelset(&sigset, SIGUSR1);
sigprocmask(SIG_SETMASK, &sigset, NULL);
puts("after unblocking SIGUSR1");
}
before kill()
before unblocking SIGUSR1
catcher() has gained control
after unblocking SIGUSR1