Unix System Progamming
Unix System Progamming
The segset_t is a data type defined in <signal.h>. It contains a collection of bit flags, with each
bit flag representing one signal defined in the system.
• The BSD UNIX and POSIX.1 define a set of API
known as sigsetops functions
#include <signal.h>
int sigemptyset(sigset_t *sigmask);
int sigaddset(sigset_t *sigmask, const int signal_num);
int sigdelset(sigset_t *sigmask, const int signal_num);
int sigfillset(sigset_t sigmask);
int sigismember(const sigset_t *sigmask, const int signal_num);
• checks whether the SIGINT signal is present in a process signal
mask and adds it to the mask if it is not there. Then clears the
SIGSEGV signal from the process signal mask.
#include <stdio.h> #include <signal.h> int main()
{
sigset_t sigmask;
sigemptyset(&sigmask); /*initialize set*/
if (sigprocmask(0, 0, &mask) == -1) /*get current signal mask*/
{
perror(“sigprocmask”);
exit(1);
}
else
sigaddset(&sigmask, SIGINT); /*set SIGINT flag*/