Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ signal(2) — Reliant UNIX 5.44c4

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

kill(2)

pause(2)

sigaction(2)

sigsend(2)

wait(2)

waitid(2)

signal(5)

signal(2)                                                         signal(2)

NAME
     signal, sigset, sighold, sigrelse, sigignore, sigpause - simplified
     signal management

SYNOPSIS
     #include <signal.h>

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

     int sighold(int sig);

     int sigignore(int sig);

     int sigpause(int sig);

     int sigrelse(int sig);

     void (*sigset(int sig, void (*disp)(int)))(int);

DESCRIPTION
     The signal() function chooses one of three ways in which receipt of
     the signal number sig is to be subsequently handled. If the value of
     func is SIGDFL, default handling for that signal will occur. If the
     value of func is SIGIGN, the signal will be ignored. Otherwise, func
     must point to a function to be called when that signal occurs. Such a
     function is called a signal handler.

     When a signal occurs, if func points to a function, first the
     equivalent of a:

          signal(sig, SIGDFL);

     is executed or an implementation-dependent blocking of the signal is
     performed. (If the value of sig is SIGILL, whether the reset to
     SIGDFL occurs is implementation-dependent.) Next the equivalent of:

          (*func)(sig);

     is executed. The func function may terminate by executing a return
     statement or by calling abort(), exit(), or longjmp(). If func() exe-
     cutes a return statement and the value of sig was SIGFPE or any other
     implementation-dependent value corresponding to a computational excep-
     tion, the behavior is undefined. Otherwise, the program will resume
     execution at the point it was interrupted.

     If the signal occurs other than as the result of calling abort(),
     kill() or raise(), the behavior is undefined if the signal handler
     calls any function in the standard library other than one of the func-
     tions listed on the sigaction() page or refers to any object with
     static storage duration other than by assigning a value to a static
     storage duration variable of type volatile sigatomict. Furthermore,
     if such a call fails, the value of errno is indeterminate.



Page 1                       Reliant UNIX 5.44                Printed 11/98

signal(2)                                                         signal(2)

     At program startup, the equivalent of:

          signal(sig, SIGIGN);

     is executed for some signals, and the equivalent of:

          signal(sig, SIGDFL);

     is executed for all other signals [see exec(2)].

     These functions provide simplified signal management for application
     processes. See signal(5) for an explanation of general signal con-
     cepts.

     signal() and sigset() are used to modify signal dispositions. sig
     specifies the signal, which may be any signal except SIGKILL and
     SIGSTOP. disp specifies the signal's disposition, which may be
     SIGDFL, SIGIGN, or the address of a signal handler. If signal() is
     used, disp is the address of a signal handler, and sig is not SIGILL,
     SIGTRAP, or SIGPWR, the system first sets the signal's disposition to
     SIGDFL before executing the signal handler. If sigset() is used and
     disp is the address of a signal handler, the system adds sig to the
     calling process' signal mask before executing the signal handler; when
     the signal handler returns, the system restores the calling process'
     signal mask to its state prior to the delivery of the signal. In addi-
     tion, if sigset() is used and disp is equal to SIGHOLD, sig is added
     to the calling process' signal mask and the signal's disposition
     remains unchanged.

     sighold() adds sig to the calling process' signal mask.

     sigrelse() removes sig from the calling process' signal mask.

     sigignore() sets the disposition of sig to SIGIGN.

     sigpause() removes sig from the calling process' signal mask and
     suspends the calling process until a signal is received. sigpause()
     function restores the process' signal mask to its original state
     before returning.

ERRORS
     The following error code descriptions are function-specific. You will
     find a general description in introprm2(2) or in errno(5).

     These functions fail if any of the following are true.

     EINTR     A signal was caught during the system call sigpause().

     The signal() function will fail if:

     EINVAL    The value of the sig argument is not a valid signal or is
               equal to SIGKILL or SIGSTOP.


Page 2                       Reliant UNIX 5.44                Printed 11/98

signal(2)                                                         signal(2)

     The signal() function may fail if:

     EINVAL    An attempt was made to set the action to SIGDFL for a sig-
               nal that cannot be caught or ignored (or both).

     The sigset(), sighold(), sigrelse(), sigignore() and sigpause() func-
     tions will fail if:

     EINVAL    The sig argument is an illegal signal number.

     The sigset(), and sigignore() functions will fail if:

     EINVAL    An attempt is made to catch a signal that cannot be caught,
               or to ignore a signal that cannot be ignored.

RESULT
     On success, signal() returns the signal's previous disposition. On
     failure, it returns SIGERR and sets errno to indicate the error.

     On success, sigset() returns SIGHOLD if the signal had been blocked
     or the signal's previous disposition if it had not been blocked. On
     failure, it returns SIGERR and sets errno to indicate the error.

     sigpause() suspends execution of the process until a signal is
     received, whereupon it returns -1 and sets errno to EINTR.

     All other functions return zero on success. On failure, they return -1
     and set errno to indicate the error.

NOTES
     The sigaction() function provides a more comprehensive and reliable
     mechanism for controlling signals. New applications should use
     sigaction() instead of signal().

     sighold() in conjunction with sigrelse() or sigpause() may be used to
     establish critical regions of code that require the delivery of a sig-
     nal to be temporarily deferred.

     If signal() or sigset() is used to set SIGCHLD's disposition to a sig-
     nal handler, SIGCHLD will not be sent when the calling process' chil-
     dren are stopped or continued.

     If any of the above functions are used to set SIGCHLD's disposition to
     SIGIGN, the calling process' child processes will not create zombie
     processes when they terminate [see exit(2)]. If the calling process
     subsequently waits for its children, it blocks until all of its chil-
     dren terminate; it then returns a value of -1 with errno set to ECHILD
     [see wait(2), waitid(2)].

SEE ALSO
     kill(2), pause(2), sigaction(2), sigsend(2), wait(2), waitid(2),
     signal(5).


Page 3                       Reliant UNIX 5.44                Printed 11/98

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