SIGNAL(2) SysV 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
signal allows the calling process to choose one of three ways 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 1 hangup
SIGINT 2* interrupt (rubout)
SIGQUIT 3* quit (ASCII FS)
SIGILL 4* illegal instruction (not reset when caught)
SIGTRAP 5* trace trap (not reset when caught)
SIGIOT 6* IOT instruction
SIGABRT 6 used by abort, replace SIGIOT in the future
SIGEMT 7* EMT instruction
SIGFPE 8* floating point exception
SIGKILL 9 kill (cannot be caught or ignored)
SIGBUS 10* bus error
SIGSEGV 11* segmentation violation
SIGSYS 12* 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 from kill
SIGUSR1 16 user defined signal 1
SIGUSR2 17 user defined signal 2
SIGCLD 18** death of a child
SIGAPOLLO 19* Apollo-specific fault
SIGSTOP 20 stop, cannot be caught, held, or ignored
SIGTSTP 21 stop signal generated from keyboard
SIGCONT 22 continue after stop
SIGCHLD 23 child status has changed
SIGTTIN 24 background read attempted from control terminal
SIGTTOU 25 background write attempted to control terminal
SIGPOLL 26| pollable event occurred
SIGIO 26 i/o is possible on a descriptor
SIGTINT 26 input record is available at control terminal
SIGXCPU 27 cpu time limit exceeded
SIGXFSZ 28 file size limit exceeded
SIGVTALRM 29 virtual time alarm
SIGPROF 30 profiling timer alarm
SIGURG 31 urgent condition present on socket
SIGWINCH 32 window size changes
(See the "Notes" section for more information on signals marked with *,
**, and |.)
func is assigned one of three values: SIG_DFL, SIG_IGN, or a function
address. SIG_DFL and SIG_IGN are defined in <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(2). See the notes under *, below.
SIG_IGN Ignore signal. The signal sig is to be ignored.
Note: the signals SIGKILL, SIGSTOP, and SIGCONT 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 or
SIGTRAP.
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), write(2), open(2), or 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 and then
the interrupted system call may return a -1 to the
calling process with errno set to EINTR.
signal 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.
The <signal.h> include file defines an integral atomic
data type sig_atomic_t. Signal handlers wishing to
use only ANSI C facilities should not refer to any
object with static storage duration other than by
assigning a value to a static storage duration
variable of type volatile sig_atomic_t. Results may
be undefined if a signal handler calls any library
routine.
Note: The signals SIGKILL and SIGSTOP cannot be
caught.
A call to signal cancels a pending signal sig except for a pending
SIGKILL signal.
ERRORS
signal will fail if sig is an illegal signal number, including SIGKILL.
(EINVAL)
SEE ALSO
tb(1), intro(2), kill(2), pause(2), ptrace(2), wait(2), setjmp(3C),
sigset(2)
kill(1) in the SysV Command Reference.
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 <signal.h>.
NOTES
The following notes apply to signals as marked in the list of signals at
the beginning of the "Description" section:
* If SIG_DFL is assigned for these signals, in addition to the process
being terminated, a process dump will be placed in the file
`node_data/system_logs/proc_dump. Use tb(1) to analyze a process
dump.
(Under some implementations, a "core image" will be made 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(2)).
- 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)
** For the signal SIGCLD, func is assigned one of three values:
SIG_DFL, SIG_IGN, or a function address. The actions prescribed by
these values are:
+ SIG_DFL The signal is to be ignored.
+ SIG_IGN The signal is to be ignored. Also, the calling process'
child processes will not create zombie processes when they
terminate (see exit(2)).
+ function address The action to be taken is the same as that
described above for func equal to function address, with one
exception: 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'
child processes terminate; it will then return a value of -1 with
errno set to ECHILD.
+ exit. If in the exiting process' 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 proceeding 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.
| 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. Otherwise, the process will never receive SIGPOLL.
Domain/OS SysV does not define a power fail signal, defined as SIGPWR on
some systems.
Domain systems send the signal SIGAPOLLO whenever a fault occurs that is
not otherwise mapped into a signal. Typical generators of SIGAPOLLO
include network failures, display-acquire timeouts, and disk full errors.
For SIGFPE, SIGILL, and SIGAPOLLO, you may use a routine like the one
below as the signal-catching func.
handler(sig, code)
int sig, code;
sig is the signal number into which the hardware faults and traps are
mapped as defined below. code is a 32-bit value. If the signal is
SIGAPOLLO, code is the Domain system status code describing the fault.
(To generate a list of Domain System status codes and brief explanations
of their meanings, run the command /systest/ssr_util/all_stcode.)
Otherwise, code is a value associated with one of the constants listed
below.
Domain system hardware traps are mapped to signals and codes as indicated
below. All of these symbols are defined in <signal.h>:
Hardware condition Signal Code
Arithmetic traps:
Integer overflow SIGFPE FPE_INTOVF_TRAP
Integer division by zero SIGFPE FPE_INTDIV_TRAP
Floating overflow trap SIGFPE FPE_FLTOVF_TRAP
Floating/decimal division by zero SIGFPE FPE_FLTDIV_TRAP
Floating underflow trap SIGFPE FPE_FLTUND_TRAP
Decimal overflow trap SIGFPE FPE_DECOVF_TRAP
Subscript-range SIGFPE FPE_SUBRNG_TRAP
Floating overflow fault SIGFPE FPE_FLTOVF_FAULT
Floating divide by zero fault SIGFPE FPE_FLTDIV_FAULT
Floating underflow fault SIGFPE FPE_FLTUND_FAULT
Length access control SIGSEGV
Protection violation SIGBUS
Reserved instruction SIGILL ILL_RESAD_FAULT
Customer-reserved instr. SIGEMT
Reserved operand SIGILL ILL_PRIVIN_FAULT
Reserved addressing SIGILL ILL_RESOP_FAULT
Trace pending SIGTRAP
Bpt instruction SIGTRAP