Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ signal(S) — System V/386 Software Development System 3.2.2b

Media Vault

Software Library

Restoration Projects

Artifacts Sought



     SIGNAL(S)                 UNIX System V                 SIGNAL(S)



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

     Syntax
          #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.  sig specifies the signal and
          func specifies the choice.

          sig 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
             SIGPOLL       22[3]   selectable event pending

          func 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 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
                    process is to be terminated with all of the
                    consequences outlined in exit(S).  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
                    process 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(S), a write(S), an open(S), or an ioctl(S)
                    system call on a slow device (like a terminal; but
                    not a file), during a pause(S) system call, or
                    during a wait(S) 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.  [EINVAL]

     See Also
          intro(S), kill(S), pause(S), ptrace(S), wait(S), setjmp(S),
          sigset(S), kill(C)

     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
              process, 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
                      writable 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(S))

                              +   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.


          [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(S)).

                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
                        true if the signal is SIGCLD with one
                        exception: while the process is executing the
                        signal-catching function, any received SIGCLD
                        signals will be ignored.  (This is the default
                        action.) A wait call must proceed any call to
                        signal that specifies SIGCLD.

              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
                        process.

                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(S)) file has a "selectable"
              event pending.  A process must specifically request that
              this signal be sent using the I_SETSIG ioctl call.
              Otherwise, the process will never receive SIGPOLL.

     Standards Conformance
          signal is conformant with:
          AT&T SVID Issue 2, Select Code 307-127;
          The X/Open Portability Guide II of January 1987;
          and ANSI X3.159-198X C Language Draft Standard, May 13,
          1988.

                                             (printed 6/20/89)



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