SIGACTION(2)        Linux Programmer's Manual        SIGACTION(2)

       sigaction,  sigprocmask,  sigpending,  sigsuspend  - POSIX
       signal handling functions.

       #include <signal.h>

       int sigaction(int signum,  const  struct  sigaction  *act,
       struct sigaction *oldact);

       int  sigprocmask(int  how,  const  sigset_t *set, sigset_t

       int sigpending(sigset_t *set);

       int sigsuspend(const sigset_t *mask);

       The sigaction system call is used  to  change  the  action
       taken by a process on receipt of a specific signal.

       signum  specifies  the  signal and can be any valid signal
       except SIGKILL and SIGSTOP.

       If act is non-null, the new action for  signal  signum  is
       installed  from  act.  If oldact is non-null, the previous
       action is saved in oldact.

       The sigaction structure is defined as

              struct sigaction {
                  void (*sa_handler)(int);
                  sigset_t sa_mask;
                  int sa_flags;
                  void (*sa_restorer)(void);

       sa_handler specifies the  action  to  be  associated  with
       signum  and may be SIG_DFL for the default action, SIG_IGN
       to ignore this signal, or a pointer to a  signal  handling

       sa_mask  gives  a  mask of signals which should be blocked
       during execution of the signal handler.  In addition,  the
       signal which triggered the handler will be blocked, unless
       the SA_NODEFER or SA_NOMASK flags are used.

       sa_flags  specifies  a  set  of  flags  which  modify  the
       behaviour  of the signal handling process. It is formed by
       the bitwise OR of zero or more of the following:

                     If signum is SIGCHLD, do not receive notifi-
                     cation when child processes stop (i.e., when
                     child  processes  receive  one  of  SIGSTOP,
                     SIGTSTP, SIGTTIN or SIGTTOU).

              SA_ONESHOT or SA_RESETHAND
                     Restore  the  signal  action  to the default
                     state  once  the  signal  handler  has  been
                     called.   (This  is  the default behavior of
                     the signal(2) system call.)

                     Provide behaviour compatible with BSD signal
                     semantics  by  making  certain  system calls
                     restartable across signals.

              SA_NOMASK or SA_NODEFER
                     Do  not  prevent  the  signal   from   being
                     received from within its own signal handler.

       The sa_restorer element is  obsolete  and  should  not  be

       The  sigprocmask  call  is used to change the list of cur-
       rently blocked signals.  The  behaviour  of  the  call  is
       dependent on the value of how, as follows.

                     The  set  of blocked signals is the union of
                     the current set and the set argument.

                     The signals in set are removed from the cur-
                     rent set of blocked signals.  It is legal to
                     attempt to unblock a  signal  which  is  not

                     The  set  of  blocked  signals is set to the
                     argument set.

       If oldset is non-null, the previous value  of  the  signal
       mask is stored in oldset.

       The sigpending call allows the examination of pending sig-
       nals (ones which have been  raised  while  blocked).   The
       signal mask of pending signals is stored in set.

       The  sigsuspend  call temporarily replaces the signal mask
       for the process with that given by mask and then  suspends
       the process until a signal is received.

       sigaction, sigprocmask, sigpending and sigsuspend return 0
       on success and -1 on error.

       EINVAL An invalid signal was specified.  This will also be
              generated  if  an  attempt  is  made  to change the
              action for SIGKILL  or  SIGSTOP,  which  cannot  be

       EFAULT act, oldact, set or oldset point to memory which is
              not a valid part of the process address space.

       EINTR  System call was interrupted.

       It is not possible to block SIGKILL or  SIGSTOP  with  the
       sigprocmask  call.   Attempts  to  do  so will be silently

       According to POSIX, the behaviour of a  process  is  unde-
       fined after it ignores a SIGFPE, SIGILL, or SIGSEGV signal
       that was not generated by the kill() or the raise()  func-
       tions.  Integer division by zero has undefined result.  On
       some architectures  it  will  generate  a  SIGFPE  signal.
       (Also  dividing the most negative integer by -1 may gener-
       ate SIGFPE.)  Ignoring this signal might lead to  an  end-
       less loop.

       POSIX (B. disallows setting the action for SIGCHLD
       to SIG_IGN.  The BSD and SYSV behaviours  differ,  causing
       BSD  software  that sets the action for SIGCHLD to SIG_IGN
       to fail on Linux.

       The POSIX spec only defines SA_NOCLDSTOP.   Use  of  other
       sa_flags is non-portable.

       The  SA_RESETHAND flag is compatible with the SVr4 flag of
       the same name.

       The SA_NODEFER flag is compatible with the  SVr4  flag  of
       the  same  name  under  kernels 1.3.9 and newer.  On older
       kernels the Linux implementation allowed  the  receipt  of
       any  signal,  not  just  the one we are installing (effec-
       tively overriding any sa_mask settings).

       The SA_RESETHAND and SA_NODEFER names for SVr4 compatibil-
       ity  are  present  only  in  library  versions  3.0.9  and

       sigaction can be called with a  null  second  argument  to
       query  the  current signal handler. It can also be used to
       check whether a given signal  is  valid  for  the  current
       machine  by  calling  it  with null second and third argu-

       See sigsetops(3) for details on manipulating signal  sets.

       POSIX,  SVr4.  SVr4 does not document the EINTR condition.

       kill(1), kill(2), killpg(2), pause(2), raise(3), siginter-
       rupt(3), signal(2), signal(7), sigsetops(3), sigvec(2)

Linux 1.3                 24 August 1995                        1