Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ signal(2) — AIX/RT 2.2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

acct

exit, _exit

kill

pause

ptrace

sigblock

sigpause

sigsetmask

sigstack

sigvec

umask

wait

setjmp, longjmp

core

signal

Purpose

     Specifies the action to take upon receipt of a signal.

Syntax

     #include <sys/signal.h>

     int (*signal (sig, action)) ( )
     int sig;
     void (*action) ( );

Description

     The  signal system  call  allows the  calling process  to
     choose one of three ways to  handle the receipt of a spe-
     cific signal.  The sig parameter specifies the signal and
     the action parameter specifies the choice.

     The sig parameter can be  any one of the following signal
     values except SIGKILL.  Each of  the names shown below is
     defined in the sys/signal.h header file with the value of
     the corresponding signal number.

                    SIGHUP       1    Hangup
                    SIGINT       2    Interrupt
                    SIGQUIT      3*   Quit
                    SIGILL       4*   Illegal  instruction  (not  reset  when
                                      caught)
                    SIGTRAP      5*   Trace trap (not reset when caught)
                    SIGIOT       6*   Abort process (see "abort")
                    SIGDANGER    7+   The system is likely to "crash" soon
                    SIGFPE       8*+  Arithmetic exception, integer divide by
                                      0, or floating point exception
                    SIGKILL      9    Kill (cannot be caught or ignored)
                    SIGBUS      10*   Specification exception
                    SIGSEGV     11*   Segmentation violation
                    SIGSYS      12*   Bad parameter to system call
                    SIGPIPE     13    Write  on  a  pipe  when  there  is  no
                                      process 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 process &c2ins.
                    SIGSAK      24    Secure attention key &c2off.
                    SIGPWR      19+   Power-fail  restart   (not  reset  when
                                      caught)
                    SIGAIO      25    Basic LAN signal for asynchronous I/O

                    SIGPTY      26    PTY  device  driver  read/write  avail-
                                      ability
                    SIGIOINT    27    I/O intervention required
                    SIGGRANT    28#   HFT monitor access wanted
                    SIGRETRACT  29#   HFT  monitor  access should  be  relin-
                                      quished
                    SIGSOUND    30#   An HFT sound control has completed exe-
                                      cution
                    SIGMSG      31#   Input data has been stored into the HFT
                                      monitor mode ring buffer

The symbols in the preceding table have the following meaning:

*   A memory image file  (core file) is created when one  of these signals is
    received.  This is  explained in more detail in  the following discussion
    of SIG_DFL.

+   These  signals require  special consideration,  as described  in "Special
    Signals."

#   For more information on the use of these signals, see "hft."

The action parameter is one of three values:  SIG_DFL, SIG_IGN, or a function
address.  The actions prescribed by these values are as follows:

SIG_DFL -- Default action:  Terminate process upon receipt of signal.

    Upon receipt of the signal sig, the receiving process is to be terminated
    with all of the consequences outlined  in the exit system call.  In addi-
    tion, a memory image file will be created in the current directory of the
    receiving process if sig is one for which an asterisk appears in the pre-
    ceding list and the following conditions are met:

    o   The effective user  ID and the real user ID  of the receiving process
        are equal.

    o   An ordinary  file named core exists  in the current directory  and is
        writable, or it can be created.  If the file must be created, it will
        have the following properties:

        -   The access  permission code  0666 (0x1B6),  modified by  the file
            creation mask (see "umask")

        -   A file owner ID that is the  same as the effective user ID of the
            receiving process

        -   A file group ID that is the same as the effective group ID of the
            receiving process.

SIG_IGN -- Ignore signal.

    The signal sig is to be ignored.

    Note:  The SIGKILL signal cannot be ignored.

function address -- Catch signal.

    Upon receipt of  the signal sig, the receiving process  is to execute the
    signal-catching function pointed to by  the action parameter.  The signal
    number sig is  passed as the only parameter to  the signal-catching func-
    tion.  Before calling  the signal-catching function, the  value of action
    for the  caught signal  is set  to SIG_DFL unless  the signal  is SIGILL,
    SIGTRAP, or SIGPWR.

    When the signal-catching  function returns, the value of  the signal mask
    upon entry  is restored, and  the receiving process resumes  execution at
    the point at which it was interrupted.

    Note that after  a signal is received,  there is a period  of time during
    which the signal  action is set to SIG_DFL and  the signal-catching func-
    tion has not had a chance to  re-establish itself as the catcher for this
    signal.  If  the signal occurs again  during that period, it  will not be
    caught.   The  sigvec  system  call offers  an  enhanced  signal-handling
    capacity to avoid this race condition.

    When a signal that is to be  caught occurs during a read, write, open, or
    ioctl system call on a slow device  (like a terminal; but not an ordinary
    file), during a pause system call, or during a wait system call that does
    not return  immediately due to the  existence of a previously  stopped or
    zombie process,  the signal-catching function  will be executed  and then
    the interrupted system call will return  a -1 to the calling process with
    errno set to EINTR.

    Note:  The SIGKILL signal cannot be caught.

    Warning:   The signal  system call  does not  check the  validity of  the
    action parameter.  If it &pointsout.,  then the process receives a memory
    fault when  the system attempts  to call  the signal handler.   If action
    points to  anything other than  a subroutine, the results  are unpredict-
    able.

     SPECIAL SIGNALS

Some signals are handled differently  from those described previously.  These
signals are:

                    SIGFPE       8*+  Arithmetic exception, integer divide by
                                      0, or floating point exception
                    SIGDANGER    7+   The system is likely to "crash" soon.
                    SIGCLD      18+   Death of a child process
                    SIGPWR      19+   Power-fail  restart   (not  reset  when
                                      caught)

See  the sys/robust.h  header  file for  the conditions  that  can cause  the
SIGDANGER  signal.  The  most  likely cause  is a  shortage  of paging  space
(PGSDANGER).  Also see  the pslotwarn, pslotkill, and  pslotpanic keywords in
"master."

For SIGDANGER and SIGPWR, the actions  prescribed by the action parameter are
as follows:

SIG_DFL            The signal is ignored.

SIG_IGN            The signal is ignored.

function address   The  signal-catching  function  pointed to  by  action  is
                   called.

For SIGCLD, the actions prescribed by the action parameter are as follows:

SIG_DFL            The signal is ignored.

SIG_IGN            The signal is  ignored.  Also, the child  processes of the
                   calling process  do not create zombie  processes when they
                   terminate.  (See "exit, _exit"  for more information about
                   zombie processes.)

function address   The  signal-catching  function  pointed to  by  action  is
                   called.   When   the  signal-catching   function  returns,
                   another SIGCLD signal is sent to the process if any zombie
                   child processes  remain to be waited  for.  Therefore, the
                   SIGCLD signal-catching  function must issue a  wait system
                   call to  eliminate the zombies,  or an infinite  loop will
                   occur.

The setting  of the action  for the SIGCLD signal  affects the wait  and exit
system calls in the following ways:

wait   If the action value of SIGCLD is set to SIG_IGN and a wait system call
       is executed, the  wait blocks until all of the  child processes of the
       calling process terminate.   It then returns a value of  -1 with errno
       set to ECHILD.

exit   If, in the  parent of the exiting process, the  action value of SIGCLD
       is set to  SIG_IGN, then the exiting process does  not create a zombie
       process.

When processing a pipeline, the shell  makes the last process in the pipeline
the parent of the  preceding processes.  A process that can  be piped into in
this manner,  and thus become the  parent of other processes,  should not set
SIGCLD to be caught.  Otherwise, it will receive unexpected SIGCLD signals.

After a  fork system call,  the child process  inherits all signals  from its
parent.

The  exec system  calls  reset  all caught  signals  to  the default  action.
Signals that  cause the default  action continue  to do so.   Ignored signals
continue to be ignored.

Return Value

Upon successful completion,  signal returns the previous value  of action for
the specified signal sig.  Otherwise, a value  of -1 is returned and errno is
set to indicate the error.

Diagnostics

The signal system call fails if the following is true:

EINVAL     The sig parameter is not a  valid signal number, or it is SIGKILL.
           &c2ins.

EPERM      The  sig parameter  is SIGSAK  and the  effective user  ID of  the
           calling process is not superuser.  &c2off.

Related Information

In  this   book:   "acct,"   "exit,  _exit,"   "kill,"   "pause,"   "ptrace,"
"sigblock,"  "sigpause,"   "sigsetmask,"    "sigstack,"  "sigvec,"  "umask,"
"wait," "setjmp, longjmp," and "core."

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