Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ () — Motorola System V 88k Release 3.2 Version 1.2C

Media Vault

Software Library

Restoration Projects

Artifacts Sought



  SIGACTION(2P)                                       SIGACTION(2P)



  NAME
       sigaction - examine or change signal action

  SYNOPSIS
       #include <signal.h>

       int sigaction(sig,act,oact)
       int sig;
       struct sigaction *act, *oact;

  DESCRIPTION
       The system defines a set of signals that may be delivered to
       a process.  Signal delivery resembles the occurrence of a
       hardware interrupt:  the signal is blocked from further
       occurrence, the current process context is saved, and a new
       one is built.  A process may specify a handler to which a
       signal is delivered, or specify that a signal is to be
       blocked or ignored . A process may also specify that a
       default action is to be taken by the system when a signal
       occurs.  Normally, signal handlers execute on the current
       stack of the process.

       All signals have the same priority.  Signal routines invoked
       by sigaction(2) execute with the signal that caused their
       invocation blocked , but other signals may yet occur.  A
       global ``signal mask'' defines the set of signals currently
       blocked from delivery to a process.  The signal mask for a
       process is initialized from that of its parent (normally 0).
       It may be changed with a sigprocmask (2) call, a sigsuspend
       (2) call, or when a signal is delivered to the process.

       When a signal condition arises for a process, the signal is
       added to a set of signals pending for the process.  If the
       signal is not currently blocked or ignored by the process
       then it is delivered to the process.  When a signal is
       delivered, the current state of the process is saved, a new
       signal mask is calculated (as described below), and the
       signal handler is invoked.  The call to the handler is
       arranged so that if the signal handling routine returns
       normally the process will resume execution in the context


  Page 1                                                   May 1989


















  SIGACTION(2P)                                       SIGACTION(2P)



       from before the signal's delivery.  If the process wishes to
       resume in a different context, then it must arrange to
       restore the previous context itself (see setjmp(3C) or
       sigsetjump(3).

       sigaction allows the calling process to examine or specify
       the action to be taken on delivery of a signal.  sig
       specifies the signal number.

       The sigaction structure is defined in <signal.h>:
            struct sigaction {
                 void (*sa_handler)();
                 sigset_t sa_mask;
                 int sa_flags;
            };

       If act is not NULL, it points to a structure specifying the
       action to be taken when the signal is delivered.  If oact is
       not NULL, the action previously associated with the signal
       is stored in the location pointed to by oact.  If act is
       NULL, signal handling is unchanged; thus if act is NULL,
       sigaction can be used to inquire about the current handling
       of a given signal.

       The saflags field of act can be used to modify the delivery
       of a specific signal.  If sig is SIGCHILP and the SA_CLDSTOP
       bit is set in saflags, SIGCHILP will be generated if a
       child process stops.

       When a signal is caught by a signal-catching function, a new
       signal mask is calculated and installed for the duration of
       the signal-catching function or until sigprocmask or
       sigsuspend is called.  This mask is formed by taking the
       union of the current signal mask and the set associated with
       the action for the signal being delivered (i.e. sa_mask) and
       then including the signal being delivered.  If and when the
       user's signal handler returns normally, the original signal
       mask is restored.

       Once an action is installed for a specific signal, it


  Page 2                                                   May 1989


















  SIGACTION(2P)                                       SIGACTION(2P)



       remains installed until another action is explicitly
       requested by another call to sigaction or until one of the
       exec functions is called.

       SIGKILL and SIGSTOP cannot be caught or ignored.  SIGCONT
       cannot be ignored.  The set of signals specified in samask
       is not allowed to block these signals.  This is silently
       enforced.

       If sigaction fails, no new signal handler is installed.

       The following is a list of the signals with names as in the
       include file <signal.h> :

       SIGHUP    1    hangup
       SIGINT    2    interrupt
       SIGQUIT   3*   quit
       SIGILL    4*   illegal instruction
       SIGTRAP   5*   trace trap
       SIGIOT    6*   IOT instruction
       SIGABRT
       SIGEMT    7*   EMT instruction
       SIGFPE    8*   floating point exception
       SIGKILL   9    kill (cannot be caught, blocked, or ignored)
       SIGBUS    10*  bus error
       SIGSEGV   11*  segmentation violation
       SIGSYS    12*  bad argument to system call
       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
       SIGCHILD  18⊕  child status has changed
       SIGPWR    19   power-fail restart
       SIGWINCH  20⊕  window size change
       SIGPOLL   22   pollable event occurred
       SIGSTOP   23†  stop (cannot be caught, blocked, or ignored)
       SIGTSTP   24†  stop signal generated from keyboard
       SIGCONT   25⊕  continue after stop (cannot be blocked)
       SIGTTIN   26†  background read attempted from control terminal


  Page 3                                                   May 1989


















  SIGACTION(2P)                                       SIGACTION(2P)



       SIGTTOU   27†  background write attempted to control terminal
       SIGURG    33⊕  urgent condition present on socket
       SIGVTALRM 37   virtual time alarm (see setitimer(2))
       SIGPROF   38   profiling timer alarm (see setitimer(2))

       The starred signals (*) in the list above cause a core image
       if not caught or ignored.

       The default action for a signal may be reinstated by setting
       svhandler to SIGDFL ; this default is termination (with a
       core image for starred signals) except for signals marked
       with ⊕ or †.  Signals marked with ⊕ are discarded if the
       action is SIG_DFL; signals marked with † cause the process
       to stop.  If svhandler is SIGIGN the signal is
       subsequently ignored, and pending instances of the signal
       are discarded.

       After a fork (2), the child inherits all signals, the signal
       mask, and the signal stack.

       exec (2) resets all caught signals to default action.
       Ignored signals remain ignored; the signal mask remains the
       same.

  RETURN VALUE
       Upon successful completion, a value of zero 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, sigaction will
       return -1 and set errno to the corresponding value:

       [EINVAL]      The value of sig is not a valid signal number,
                     or an attempt was made to supply an action for
                     a signal that cannot be caught or ignored.

       [EFAULT]      act and/or oact is an invalid address.

  SEE ALSO


  Page 4                                                   May 1989


















  SIGACTION(2P)                                       SIGACTION(2P)



       exec(2), kill(2), sigsetops(2), sigprocmask(2),
       sigsuspend(2), sigvec(2).








































  Page 5                                                   May 1989
















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