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

NAME

6       sigaction, rt_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
17
18       siginfo_t: _POSIX_C_SOURCE >= 199309L
19

DESCRIPTION

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