1SIGACTION(2)               Linux Programmer's Manual              SIGACTION(2)
2
3
4

NAME

6       sigaction - examine and change a signal action
7

SYNOPSIS

9       #include <signal.h>
10
11       int sigaction(int signum, const struct sigaction *act,
12                     struct sigaction *oldact);
13
14   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
15
16       sigaction(): _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _POSIX_SOURCE
17

DESCRIPTION

19       The  sigaction()  system  call  is used to change the action taken by a
20       process on receipt of a specific signal.  (See signal(7) for  an  over‐
21       view of signals.)
22
23       signum  specifies the signal and can be any valid signal except SIGKILL
24       and SIGSTOP.
25
26       If act is non-NULL, the new action for signal signum is installed  from
27       act.  If oldact is non-NULL, the previous action is saved in oldact.
28
29       The sigaction structure is defined as something like:
30
31           struct sigaction {
32               void     (*sa_handler)(int);
33               void     (*sa_sigaction)(int, siginfo_t *, void *);
34               sigset_t   sa_mask;
35               int        sa_flags;
36               void     (*sa_restorer)(void);
37           };
38
39       On  some  architectures  a  union  is  involved:  do not assign to both
40       sa_handler and sa_sigaction.
41
42       The sa_restorer element is obsolete and should not be used.  POSIX does
43       not specify a sa_restorer element.
44
45       sa_handler specifies the action to be associated with signum and may be
46       SIG_DFL for the default action, SIG_IGN to ignore  this  signal,  or  a
47       pointer to a signal handling function.  This function receives the sig‐
48       nal number as its only argument.
49
50       If SA_SIGINFO is specified in sa_flags, then sa_sigaction  (instead  of
51       sa_handler)  specifies  the  signal-handling function for signum.  This
52       function receives the signal number as its first argument, a pointer to
53       a  siginfo_t as its second argument and a pointer to a ucontext_t (cast
54       to void *) as its third argument.
55
56       sa_mask specifies a mask of signals  which  should  be  blocked  (i.e.,
57       added  to  the signal mask of the thread in which the signal handler is
58       invoked) during execution of the signal handler.  In addition, the sig‐
59       nal  which triggered the handler will be blocked, unless the SA_NODEFER
60       flag is used.
61
62       sa_flags specifies a set of flags which modify the behavior of the sig‐
63       nal.  It is formed by the bitwise OR of zero or more of the following:
64
65           SA_NOCLDSTOP
66                  If signum is SIGCHLD, do not receive notification when child
67                  processes stop (i.e., when  they  receive  one  of  SIGSTOP,
68                  SIGTSTP,  SIGTTIN  or SIGTTOU) or resume (i.e., they receive
69                  SIGCONT) (see wait(2)).  This flag is only  meaningful  when