Pegasus InfoCorp: Web site design and web software development company

SIGACTION (2)

POSIX signal handling functions.

SYNOPSIS

    #include <signal.h> int sigaction(int signum , const struct sigaction * act , struct sigaction * oldact ); int sigprocmask(int how , const sigset_t * set , sigset_t * oldset ); int sigpending(sigset_t * set ); int sigsuspend(const sigset_t * mask );

DESCRIPTION

    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);
          void (*sa_sigaction)(int, siginfo_t *, void *);
          sigset_t sa_mask;
          int sa_flags;
          void (*sa_restorer)(void);
      }
      

    The sa_restorer element is obsolete and should not be used. POSIX does not specify a sa_restorer element.

    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 function.

    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:

      SA_NOCLDSTOP

        If signum is SIGCHLD , do not receive notification 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.)

      SA_RESTART

        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.

      SA_SIGINFO

        The signal handler takes 3 arguments, not one. In this case, sa_sigaction should be set instead of sa_handler . (The sa_sigaction field was added in Linux 2.1.86.)

    The siginfo_t parameter to sa_sigaction is a struct with the following elements

      4 13 24
      siginfo_t {
              int     si_signo;       /* Signal number */
              int     si_errno;       /* An errno value */
              int     si_code;        /* Signal code */
              pid_t   si_pid; /* Sending process ID */
              uid_t   si_uid; /* Real user ID of sending process */
              int     si_status;      /* Exit value or signal */
              clock_t si_utime;       /* User time consumed */
              clock_t si_stime;       /* System time consumed */
              sigval_t        si_value;       /* Signal value */
              int     si_int; /* POSIX.1b signal */
              void *  si_ptr; /* POSIX.1b signal */
              void *  si_addr;        /* Memory location which caused fault */
              int     si_band;        /* Band event */
              int     si_fd;  /* File descriptor */
      }
      

    si_signo , si_errno and si_code are defined for all signals. kill (2), POSIX.1b signals and SIGCHLD fill in si_pid and si_uid . SIGCHLD also fills in si_status , si_utime and si_stime . si_int and si_ptr are specified by the sender of the POSIX.1b signal.