MiniUnix/usr/man/man2/signal.2

Find at most related files.
including files from this version of Unix.

.th SIGNAL II 8/5/73
.sh NAME
signal \*- catch or ignore signals
.sh SYNOPSIS
(signal = 48.)
.br
.ft B
sys  signal; sig; label
.ft R
.br
(old value in r0)
.s3
.ft B
signal(sig, func)
.br
int (*func)( );
.ft R
.sh DESCRIPTION
A
.it signal
is generated by some abnormal event,
initiated either by user at a typewriter (quit, interrupt),
by a program error (bus error, etc.),
or by request of another program (kill).
Normally all signals
cause termination of the receiving process,
but this call allows them either to be ignored
or to cause an interrupt to a specified location.
Here is the list of signals:
.s3
.lp +10 5
1	hangup
.lp +10 5
2	interrupt
.lp +10 5
3*	quit
.lp +10 5
4*	illegal instruction (not reset when caught)
.lp +10 5
5*	trace trap (not reset when caught)
.lp +10 5
6*	IOT instruction
.lp +10 5
7*	EMT instruction
.lp +10 5
8*	floating point exception
.lp +10 5
9	kill (cannot be caught or ignored)
.lp +10 5
10*	bus error
.lp +10 5
11*	segmentation violation
.lp +10 5
12*	bad argument to system call
.lp +10 5
13	write on a pipe with no one to read it
.s3
.i0
In the assembler call, if
.it label
is 0,
the process is terminated
when the signal occurs; this is the default action.
If
.it label
is odd, the signal is ignored.
Any other even
.it label
specifies an address in the process
where an interrupt is simulated.
An RTI or RTT instruction will return from the
interrupt.
Except as indicated,
a signal is reset to 0 after being caught.
Thus if it is desired to
catch every such signal,
the catching routine must
issue another
.it signal
call.
.s3
In C,
if
.it func
is 0, the default action
for signal
.it sig
(termination)
is reinstated.
If
.it func
is 1,
the signal is ignored.
If
.it func
is non-zero and
even, it is assumed to be the address
of a function entry point.
When the signal occurs,
the function will be called.
A return from the function will
continue the process at the point it was interrupted.
As in the assembler call,
.it signal
must in general be called again to catch subsequent signals.
.s3
When a caught signal occurs
during certain system calls, the call terminates prematurely.
In particular this can occur
during a
.it read
or
.it write
on a slow device (like a typewriter; but not a file);
and during
.sleep
or
.it wait.
When such a signal occurs, the saved user status
is arranged in such a way that when return from the
signal-catching takes place, it will appear that the
system call returned a characteristic error status.
The user's program may then, if it wishes,
re-execute the call.
.s3
The starred signals in the list above cause a core image
if not caught or ignored.
.s3
The value of the call is the old action defined for the signal.
.s3
After a
.it fork
(II)
the child inherits
all signals.
.it Exec
(II)
resets all
caught signals to default action.
.sh "SEE ALSO"
kill (I), kill (II),
ptrace (II),
reset (III)
.sh DIAGNOSTICS
The error bit
(c-bit)
is set if the
given signal is out of range.
In C, a \*-1 indicates an error;
0 indicates success.
.sh BUGS