Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

kill(2)

sigprocmask(2)

sigsuspend(2)

sigset(2)



  sigaction(2)                        CLIX                        sigaction(2)



  NAME

    sigaction - Specifies the action to take upon delivery of a signal

  LIBRARY

    Standard C Library (libc.a)

  SYNOPSIS

    #include <signal.h>

    int sigaction(
      int signal ,
      struct *action ,
      struct *oaction );

  PARAMETERS

    signal    Specifies the signal; acceptable values are defined in
              <sys/signal.h>.

    action    Points to a structure specifying the action to be associated
              with the specified signal, if its value is not NULL.

    oaction   Points to a structure specifying the action previously
              associated with the specified signal, if its value is not NULL.

  DESCRIPTION

    The sigaction() function allows the calling process to examine and/or
    change the action associated with a specific signal.

    The sigaction() structure, used to describe an action to be taken, is
    defined in the <signal.h> header to include the following members:

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

    If the action parameter is not NULL, it points to a structure specifying
    the action to be associated with the specified signal.  If the oaction
    parameter is not NULL, the action previously associated with the signal is
    stored in the location to which the oaction parameter points.  If the
    action parameter is NULL, signal handling is unchanged by this function
    call; thus, the call can be used to inquire about the current handling of
    a given signal.

    The signal parameter can be assigned any one of the following except



  2/94 - Intergraph Corporation                                              1






  sigaction(2)                        CLIX                        sigaction(2)



    SIGKILL or SIGSTOP:

      SIGHUP    01   hangup
      SIGINT    02   interrupt
      SIGQUIT   03   quit
      SIGILL    04   illegal instruction (not reset when caught)
      SIGTRAP   05   trace trap (not reset when caught)
      SIGEMT    07   EMT instruction
      SIGFPE    08   floating-point exception
      SIGKILL   09   kill (cannot be caught or ignored)
      SIGBUS    10   bus error
      SIGSEGV   11   segmentation violation
      SIGSYS    12   bad argument to function
      SIGPIPE   13   write on a pipe with no one to read it
      SIGALRM   14   alarm clock
      SIGTERM   15   software termination signal
      SIGUSR1   16   user-defined signal 1
      SIGUSR2   17   user-defined signal 2
      SIGCLD    18   death of a child or child has stopped
      SIGCHLD   18   death of a child or child has stopped
      SIGPWR    19   power failure
      SIGURG    20   urgent condition present on socket
      SIGIO     21   I/O is possible on a socket (see the fcntl() function)
      SIGPOLL   22   selectable event pending
      SIGSTOP   23   stop (cannot be caught or ignored)
      SIGTSTP   24   stop signal generated from keyboard
      SIGTTIN   25   background read attempted from control terminal
      SIGTTOU   26   background write attempted from control terminal
      SIGCONT   27   continue if stopped (cannot be ignored)

    The sa_handler member is assigned one of three values:  SIG_DFL, SIG_IGN,
    or a function address.  SIG_DFL and SIG_IGN are defined in the include
    file <sys/signal.h>.  SIG_DFL and SIG_IGN are macros that expand to a
    constant expression of type pointer to function returning void and has a
    unique value that matches no declarable function.

    The actions prescribed by the values of the sa_handler member are as
    follows:

    SIG_DFL   This action terminates a process on receipt of a signal.  When
              the signal specified by the signal parameter is received, the
              receiving process is to be terminated with all of the
              consequences outlined in the exit() function.

    SIG_IGN   This action causes the signal specified by the signal parameter
              to be ignored.  Note that the SIGKILL and SIGSTOP signals cannot
              be ignored.
    function  When the signal specified by the signal parameter is received,
              the receiving process will execute the signal-catching function
              to which sa_handler points.  Note that the SIGKILL and SIGSTOP
              signals cannot be caught.



  2                                              Intergraph Corporation - 2/94






  sigaction(2)                        CLIX                        sigaction(2)



    The sa_mask member can be used to specify that individual signals, in
    addition to those in the process signal mask, be blocked from being
    delivered while the signal handler function specified in the sa_handler is
    executing.  The SIGKILL and SIGSTOP signals cannot be added to the signal
    mask using this mechanism.  If adding these signals is attempted, no error
    is indicated.

    The sa_flags member can be used to modify the behavior of the specified
    signal.  The SA_NOCLDSTOP flag bit, defined in the <signal.h> header, can
    be set in sa_flags so that no SIGCHLD signal will be generated when the
    child processes stop.

    If signal is SIGCHLD and the SA_NOCLDSTOP flag is not set in sa_flags, a
    SIGCHLD signal is generated for the calling process whenever any of its
    child processes stop.  If signal is SIGCHLD and the SA_NOCLDSTOP flag is
    set in sa_flags, a SIGCHLD is not generated in this way.

    When a signal is caught by a signal-catching function installed by the
    sigaction() function, a new signal mask is calculated and installed for
    the duration of the signal-catching function (or until a call to either
    the sigprocmask() or sigsuspend() function is made).  This mask is formed
    by taking the union of the current signal mask and the value of the
    sa_mask for the signal being delivered, and then including the signal
    being delivered.  If the user's signal handler returns normally, the
    original signal mask is restored.

    Once an action is installed for a specific signal, it remains installed
    until another action is explicitly requested, or until one of the exec()
    functions is called.

    If the sigaction() function fails, no new signal handler is installed.

  RETURN VALUES

    Upon successful completion a value of 0 is returned.  Otherwise, a value
    of -1 is returned and errno is set to indicate the error.

  ERRORS

    If any of the following conditions occur, the sigaction() function returns
    -1 and sets errno to the corresponding value:

    [EINVAL]   The value of the signal parameter is an invalid or unsupported
               signal number.  This error also occurs if an attempt was made
               to catch a signal that cannot be caught or to ignore a signal
               that cannot be ignored.

  RELATED INFORMATION

    Functions: kill(2), sigprocmask(2), sigsuspend(2), sigset(2)




  2/94 - Intergraph Corporation                                              3




Typewritten Software • bear@typewritten.org • Edmonds, WA 98026