Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ sigaction(2) — DG/UX R4.11

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

kill(2)

signal(2)

sigprocmask(2)

sigsuspend(2)

sigsetops(3C)



sigaction(2)                      SDK R4.11                     sigaction(2)


NAME
       sigaction - examine or change signal action

SYNOPSIS
       #include <signal.h>

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

   where:
       sig       A signal number.

       act       NULL, or a new action to be installed for sig.

       oact      NULL, or the current action associated with sig.  If act is
                 not NULL and the call is successful, oact will be replaced
                 by act.

DESCRIPTION
       Use sigaction(2) to examine or specify the action to be associated
       with a specific signal. The argument sig specifies the signal;
       acceptable values are defined in <sys/signal.h>.

       The structure sigaction, used to describe an action to be taken, is
       defined in the header <sys/signal.h>.  It includes the following
       members:

         Member       Member              Description
          Type         Name

       void (*)()   sa_handler   SIG_DFL, SIG_IGN, or pointer
                                 to a function.

       sigset_t     sa_mask      Additional set of signals to
                                 be blocked during execution of
                                 signal-catching function.

       int          sa_flags     Special flags to affect
                                 behavior of signal.

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

       The sahandler field of the sigaction structure identifies the action
       to be associated with the specified signal.  It may have any of the
       values specified above.

       If the sahandler field specifies a signal-catching function, the
       samask field identifies a set of signals to be added to the
       process's set of blocked signals before the signal-catching function
       is invoked. In addition to these, the signal that caused the handler
       to be invoked will be added to the set of blocked signals unless the
       SA_NODEFER flag has been specified (see the saflags description
       below).  The signals SIGKILL and SIGSTOP cannot be added to a
       process's blocked signals. If samask includes these signals, they
       will be ignored.

       Use the saflags field to modify the delivery of the specified
       signal.  The values you can specify, defined in the header
       <sys/signal.h>, are listed below:

       Symbolic       Description
       Constant

       SA_ONSTACK     If set and the signal is caught, and an
                      alternate signal stack has been
                      declared, the signal is delivered to the
                      calling process using the alternate
                      stack.  Otherwise, the signal is
                      delivered on the same stack as the main
                      program.

       SA_RESETHAND   If set and the signal is caught, the
                      action of the signal is reset to
                      SIG_DFL.  (Note: SIGKILL, SIGTRAP, and
                      SIGPWR cannot be automatically reset
                      when delivered. With these signals,
                      setting SA_RESETHAND has no effect.)

       SA_NODEFER     If set and the signal is caught, sig
                      will not be automatically blocked while
                      the handler is active.

       SA_RESTART     If set and the signal is caught, and if
                      the system call is restartable, the
                      kernel will restart the system call on
                      behalf of the caller after a signal
                      handler completes processing some signal
                      that has interrupted the call.  If this
                      flag is not set, a system call that is
                      interrupted will return EINTR. A non-
                      restartable system call that is
                      interrupted will return EINTR regardless
                      of this flag.

                      The restartable system calls are:
                      dgxtrace(2), getmsg(2), getpmsg(2),
                      ioctl(2), poll(2), pread(2), putmsg(2),
                      putpmsg(2), pwrite(2), read(2),
                      readv(2), wait(2), wait3(2), wait4(2),
                      waitid(2), waitpid(2), write(2),
                      writev(2).

       SA_SIGINFO     If this flag is not set and the signal
                      is caught, sig is passed as the only
                      argument to the signal handling
                      function.  If this flag is set and the
                      signal is caught, two additional
                      arguments will be passed to the signal
                      handling function.  If the second
                      argument is not equal to NULL, it will
                      point to an object of type siginfo_t,
                      which will explain the reason the signal
                      was generated (see siginfo.h).  The
                      third argument will point to an object
                      of type ucontext_t, which will describe
                      the receiving process' context at the
                      time it received the signal (see
                      ucontext.h).

       SA_NOCLDWAIT   If set and sig equals SIGCHLD, the
                      system will clean up after the calling
                      process's dead children.  If the calling
                      process subsequently calls wait(), it
                      will block until all of its processes
                      terminate and then return a value of -1
                      with errno set to ECHILD.

       SA_NOCLDSTOP   If set and sig equals SIGCHLD, sig will
                      not be sent to the calling process when
                      its child processes stop.

       When a signal is caught by a signal-catching function installed by
       sigaction(2), a new signal mask is calculated and installed for the
       duration of the signal-catching function (or until a call to either
       sigprocmask(2) or sigsuspend(2).  This mask is formed by taking the
       union of the current signal mask and the value of the samask for the
       signal being delivered, and then including the signal being delivered
       (unless the SA_NODEFER flag is set, as described above).  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 remains
       installed until another action is explicitly requested by a call to
       sigaction(2) or exec(2).  This behavior may be modified by using the
       SA_RESTART flag as described above.

       If the previous action for sig had been established by the signal(2)
       function, defined in the C Standard, the values of the fields
       returned in the structure pointed to by oact are unspecified, and in
       particular oact->svhandler is not necessarily the same value passed
       to signal(2).  However, if a pointer to the same structure or a copy
       thereof is passed to a subsequent call to sigaction(2) via the act
       argument, handling of the signal is as if the original call to
       signal(2) were repeated.

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

RETURN VALUE
       0      Successful completion.

       -1     An error occurred.  errno is set to indicate the error.

DIAGNOSTICS
       If any of the following conditions occur, the sigaction(2) function
       shall return -1 and set errno to the corresponding value:

       EINVAL    The value of the sig argument is an invalid or unsupported
                 signal number, or an attempt was made to catch a signal
                 that cannot be caught or to ignore a signal that cannot be
                 ignored.  See <signal.h>.

       EFAULT    act or oact points to an invalid location in the user's
                 address space.

SEE ALSO
       kill(2), signal(2), sigprocmask(2), sigsuspend(2), sigsetops(3C),
       <signal.h>.

COPYRIGHTS
       Portions of this text are reprinted from IEEE Std 1003.1-1988,
       Portable Operating System Interface for Computer Environment,
       copyright © 1988 by the Institute of Electrical and Electronics
       Engineers, Inc., with the permission of the IEEE Standards
       Department.  To purchase IEEE Standards, call 800/678-IEEE.

       In the event of a discrepancy between the electronic and the original
       printed version, the original version takes precedence.


Licensed material--property of copyright holder(s)

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