Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

intro(2)

kill(2)

pause(2)

ptrace(2)

sigset(2)

wait(2)

setjmp(3C)

kill(1)



          signal(2)            INTERACTIVE UNIX System            signal(2)



          NAME
               signal - specify what to do upon receipt of a signal

          SYNOPSIS
               #include <signal.h>

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

          DESCRIPTION
               The signal system call allows the calling process to choose
               one of three ways in which it is possible to handle the
               receipt of a specific signal.  The sig argument specifies
               the signal and the func argument specifies the choice.

               The sig argument can be assigned any one of the following
               except SIGKILL:

               SIGHUP     01      hangup
               SIGINT     02      interrupt
               SIGQUIT    03[1]   quit
               SIGILL     04[1]   illegal instruction (not reset when caught)
               SIGTRAP    05[1]   trace trap (not reset when caught)
               SIGIOT     06[1]   IOT instruction
               SIGABRT    06      used by abort, replaces SIG10T
               SIGEMT     07[1]   EMT instruction
               SIGFPE     08[1]   floating point exception
               SIGKILL    09      kill (cannot be caught or ignored)
               SIGBUS     10[1]   bus error
               SIGSEGV    11[1]   segmentation violation
               SIGSYS     12[1]   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
               SIGCLD     18[2]   death of a child
               SIGPWR     19[2]   power fail
               SIGWINCH   20      window change
               SIGPOLL    22[3]   selectable event pending
               Job control signals:
               SIGCONT     23    continue if stopped
               SIGSTOP     24    stop (cannot be caught)
               SIGTSTP     25    interactive stop
               SIGTTIN     26    background read attempt
               SIGTTOU     27    background write attempt

               The func argument 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 signal.h.  Each is a macro that
               expands to a constant expression of type pointer to function
               returning void, and has a unique value that matches no


          Rev. 1.2                                                   Page 1





          signal(2)            INTERACTIVE UNIX System            signal(2)



               declarable function.

               The actions prescribed by the values of func are as follows:

                 SIG_DFL -terminate process upon receipt of a signal
                         Upon receipt of the signal sig, the receiving pro-
                         cess is to be terminated with all of the conse-
                         quences outlined in exit(2).  See NOTE [1] below.

                 SIG_IGN -ignore signal
                         The signal sig is to be ignored.

                         Note:  The signal SIGKILL cannot be ignored.

                 function address -catch signal
                         Upon receipt of the signal sig, the receiving pro-
                         cess is to execute the signal-catching function
                         pointed to by func.  The signal number sig will be
                         passed as the only argument to the signal-catching
                         function.  Additional arguments are passed to the
                         signal-catching function for hardware-generated
                         signals.  Before entering the signal-catching
                         function, the value of func for the caught signal
                         will be set to SIG_DFL unless the signal is
                         SIGILL, SIGTRAP, or SIGPWR.

                         Upon return from the signal-catching function, the
                         receiving process will resume execution at the
                         point it was interrupted.

                         When a signal that is to be caught occurs during a
                         read(2), a write(2), an open(2), or an ioctl(2)
                         system call on a slow device (like a terminal; but
                         not a file), during a pause(2) system call, or
                         during a wait(2) 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. Then the interrupted
                         system call may return a -1 to the calling process
                         with errno set to EINTR.

                         The signal system call will not catch an invalid
                         function argument, func, and results are undefined
                         when an attempt is made to execute the function at
                         the bad address.

                         Note: The signal SIGKILL cannot be caught.

               A call to signal cancels a pending signal sig except for a
               pending SIGKILL signal.

               The signal system call will fail if sig is an illegal signal
               number, including SIGKILL.


          Rev. 1.2                                                   Page 2





          signal(2)            INTERACTIVE UNIX System            signal(2)



          SEE ALSO
               intro(2), kill(2), pause(2), ptrace(2), sigset(2), wait(2),
               setjmp(3C).
               kill(1) in the INTERACTIVE UNIX User's/System
               Administrator's Reference Manual.

          DIAGNOSTICS
               Upon successful completion, signal returns the previous
               value of func for the specified signal sig.  Otherwise, a
               value of SIG_ERR is returned and errno is set to indicate
               the error.  SIG_ERR is defined in the include file signal.h.

          NOTES
               [1] If SIG_DFL is assigned for these signals, in addition to
                   the process being terminated, a ``core image'' will be
                   constructed in the current working directory of the pro-
                   cess, if the following conditions are met:

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

                           An ordinary file named core exists and is writ-
                           able or can be created.  If the file must be
                           created, it will have the following properties:

                                   ⊕  A mode of 0666 modified by the file
                                      creation mask (see umask(2)).

                                   ⊕  A file owner ID that is the same as
                                      the effective user ID of the receiv-
                                      ing process.

                                   ⊕  A file group ID that is the same as
                                      the effective group ID of the receiv-
                                      ing process.

               [2] For the signals SIGCLD and SIGPWR, func is assigned one
                   of three values:  SIG_DFL, SIG_IGN, or a function
                   address.  The actions prescribed by these values are:

                     SIG_DFL -ignore signal
                             The signal is to be ignored.

                     SIG_IGN -ignore signal
                             The signal is to be ignored.  Also, if sig is
                             SIGCLD, the calling process's child processes
                             will not create zombie processes when they
                             terminate (see exit(2)).

                     function address -catch signal
                             If the signal is SIGPWR, the action to be
                             taken is the same as that described above for
                             func equal to function address.  The same is


          Rev. 1.2                                                   Page 3





          signal(2)            INTERACTIVE UNIX System            signal(2)



                             true if the signal is SIGCLD with one excep-
                             tion:  while the process is executing the
                             signal-catching function, any received SIGCLD
                             signals will be ignored.  (This is the default
                             action.)

                   In addition, SIGCLD affects the wait and exit system
                   calls as follows:

                     wait    If the func value of SIGCLD is set to SIG_IGN
                             and a wait is executed, the wait will block
                             until all of the calling process's child
                             processes terminate; it will then return a
                             value of -1 with errno set to ECHILD.

                     exit    If in the exiting process's parent process the
                             func value of SIGCLD is set to SIG_IGN, the
                             exiting process will not create a zombie pro-
                             cess.

                     When processing a pipeline, the shell makes the last
                     process in the pipeline the parent of the preceding
                     processes.  A process that may be piped into in this
                     manner (and thus become the parent of other processes)
                     should take care not to set SIGCLD to be caught.

               [3] SIGPOLL is issued when a file descriptor corresponding
                   to a STREAMS (see intro(2)) file has a ``selectable''
                   event pending.  A process must specifically request that
                   this signal be sent using the I_SETSIG ioctl call.  Oth-
                   erwise, the process will never receive SIGPOLL.
























          Rev. 1.2                                                   Page 4



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