SIGNAL(2) DOMAIN/IX Reference Manual (SYS5) SIGNAL(2)
NAME
signal - specify what to do upon receipt of a signal
USAGE
#include <signal.h>
int (*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 speci-
fies the signal and func specifies the choice.
Sig can be any one of the following except SIGKILL:
SIGHUP 1 hang-up
SIGINT 2 interrupt
SIGQUIT 3 quit
SIGILL 4 illegal instruction
SIGTRAP 5 trace trap
SIGIOT 6 IOT instruction
SIGEMT 7 EMT instruction
SIGFPE 8 floating-point exception
SIGKILL 9 kill (cannot be caught, blocked, 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
SIGUSR1 16 user-defined signal 1
SIGUSR2 17 user-defined signal 2
SIGCLD 18 death of a child
SIGPWR 19 power-fail restart
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
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
Func is assigned one of three values: SIG_DFL, SIG_IGN, or a
function address. The actions prescribed by these values
are as follows:
Printed 5/10/85 SIGNAL-1
SIGNAL(2) DOMAIN/IX Reference Manual (SYS5) SIGNAL(2)
SIG_DFL - terminate process upon receipt
Upon receipt of the signal sig, the receiving process
will be terminated with the consequences outlined in
exit(2).
SIG_IGN - ignore signal
Ignore the signal sig.
Note: The signal SIGKILL cannot be ignored.
function address - catch signal
Upon receipt of the signal sig, the receiving process
executes the signal-catching function defined by func.
The signal number sig will be passed to the signal-
catching function as the only argument. 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 inter-
rupted.
When a signal that is to be caught occurs during a read, a
write, an open, or an ioctl system call on a slow device,
during a pause system call, or during a wait system call
that does not return immediately, the signal catching func-
tion will be executed and then the interrupted system call
may return a -1 to the calling process and set errno to
EINTR.
Note: The signal SIGKILL cannot be caught.
A call to signal cancels a pending signal sig except for a
pending SIGKILL signal.
RETURN VALUE
Upon successful completion, signal returns the previous
value of func for the specified signal sig. Otherwise, a
value of -1 is returned and errno is set to indicate the
error.
ERRORS
[EINVAL] Signal will fail if sig is an illegal signal
number, including SIGKILL.
WARNING
Two other signals that behave differently than the signals
described above exist in this release of the system; they
are:
SIGNAL-2 Printed 5/10/85
SIGNAL(2) DOMAIN/IX Reference Manual (SYS5) SIGNAL(2)
SIGCLD 18 death of a child (reset when caught)
SIGPWR 19 power fail (not reset when caught)
These signals are included only for compatibility with pre-
vious versions. We discourage their use in new programs.
For these signals, func is assigned one of three values:
SIG_DFL, SIG_IGN, or a function address. The actions
prescribed by these values are as follows:
SIG_DFL - ignore signal
Ignore the signal.
SIG_IGN - ignore signal
Ignore the signal. Also, if sig is SIGCLD, the
calling process' child processes will not create
``pseudo-processes" when they terminate; see
exit(2).
function address - catch signal
If the signal is SIGPWR, the action is the same as
that described above for func equal to function
address. The same is true if the signal is SIGCLD
except that, while the process is executing the
signal-catching function, any received SIGCLD sig-
nals will be queued and the signal-catching func-
tion will be re-entered until the queue is empty.
The SIGCLD affects two other system calls (wait(2), and
exit(2)) in the following ways:
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 pseudo-process.
When processing a pipeline, the Shell makes the last pro-
cess in the pipeline the parent of the proceeding
processes. A process that may be piped into (and thus
become the parent of other processes) should not let
SIGCLD be caught.
RELATED INFORMATION
kill(1), kill(2), pause(2), wait(2), setjmp(3C)
Printed 5/10/85 SIGNAL-3