SIGSYS(2J) GENIX Programmer's Manual SIGSYS(2J)
NAME
sigsys - catch or ignore signals
SYNOPSIS
#include <signal.h>
(*sigsys(sig, func))()
void (*func)();
cc ... -ljobs
DESCRIPTION
N.B.: The system currently supports two signal implementations. The
one described in signal(2) is standard in version 7 UNIX systems,
and retained for backward compatibility as it is different in a
number of ways. The one described here (with the interface in sig-
set(3)) provides for the needs of the job control mechanisms (see
jobs(3)) used by csh(1), and corrects the bugs in the standard
implementation of signals, allowing programs which process inter-
rupts to be written reliably.
The routine sigsys is not normally called directly; rather the rou-
tines of sigset(3) should be used. These routines are kept in the
``jobs'' library, accessible by giving the loader option -ljobs.
The features described here are less portable then those of sig-
nal(2) and should not be used in programs which are to be moved to
other versions of UNIX.
A signal is generated by some abnormal event, initiated by a user at
a terminal (quit, interrupt, stop), by a program error (bus error,
etc.), by request of another program (kill), or when a process is
stopped because it wishes to access its control terminal while in
the background (see tty(4)). Signals are optionally generated when
a process resumes after being stopped, when the status of child
processes changes, or when input is ready at the control terminal.
Most signals cause termination of the receiving process if no action
is taken; some signals instead cause the process receiving them to
be stopped, or are simply discarded if the process has not requested
otherwise. Except for SIGKILL and SIGSTOP, which cannot be blocked,
the sigsys call allows signals either to be ignored, held until a
later time (protecting critical sections in the process), or to
cause an interrupt to a specified location. Here is the list of all
signals with names as specified in the file /usr/include/signal.h:
SIGHUP 1 hangup
SIGINT 2 interrupt
SIGQUIT 3* quit
SIGILL 4* illegal instruction (not reset when caught)
SIGTRAP 5* trace trap (not reset when caught)
SIGIOT 6* IOT instruction
SIGEMT 7* EMT instruction
SIGFPE 8* floating point exception
Printed 11/16/83 1
SIGSYS(2J) GENIX Programmer's Manual SIGSYS(2J)
SIGKILL 9 kill (cannot be caught, held 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
16 unassigned
SIGSTOP 17'
|+'stop (cannot be caught, held or ignored)
SIGTSTP 18'
|+'stop signal generated from keyboard
SIGCONT 19@ continue after stop
SIGCHLD 20@ child status has changed
SIGTTIN 21'
|+'background read attempted from control terminal
SIGTTOU 22'
|+'background write attempted to control terminal
SIGTINT 23@ input record is available at control terminal
SIGXCPU 24 cpu time limit exceeded (see vlimit(2))
SIGXFSZ 25 file size limit exceeded (see vlimit(2))
SIGDVZ 26* integer divide by zero
SIGNMI 27 MMU debugging interrupt
SIGBPT 28 breakpoint instruction
SIGPROF 29@ profiling interrupt (temporary implementation)
The starred signals in the list above cause a core image if not
caught, held, or ignored.
If func is SIG_DFL, the default action for signal sig is reinstated;
this default is termination (with a core image for starred signals)
except for signals marked with @ or '
|+'. Signals marked with @ are
discarded if the action is SIG_DFL; signals marked with '
|+' cause
the process to stop. If func is SIG_HOLD the signal is remembered
if it occurs, but is not presented to the process; it may be
presented later if the process changes the action for the signal.
If func is SIG_IGN, the signal is subsequently ignored and pending
instances of the signal are discarded (i.e., if the action was pre-
viously SIG_HOLD). Otherwise when the signal occurs, func will be
called.
A return from the function will continue the process at the point it
was interrupted. Except as indicated, a signal, set with sigsys, is
reset to SIG_DFL after being caught. However by specifying
DEFERSIG(func) as the last argument to sigsys, one causes the action
to be set to SIG_HOLD before the interrupt is taken, so that recur-
sive instances of the signal cannot occur during handling of the
signal.
When a caught signal occurs during certain system calls, the call
terminates prematurely. In particular this can occur during a
read(2) or write(2) on a slow device (such as a terminal, but not a
file) and during a pause(2) or wait(2). When a signal occurs during
one of these calls, the saved user status is arranged in such a way
that, when return from the signal-catching routine takes place, it
will appear that the system call returned an error status. The
Printed 11/16/83 2
SIGSYS(2J) GENIX Programmer's Manual SIGSYS(2J)
user's program may then, if it wishes, re-execute the call. Read
and write calls that have done no I/O, ioctl(2) calls blocked with
SIGTTOU, and wait3(2J) calls are restarted.
The value of sigsys is the previous (or initial) value of func for
the particular signal.
The system provides two other functions by or-ing bits into the sig-
nal number: SIGDOPAUSE causes the process to pause after changing
the signal action. It can be used to atomically re-enable a held
signal that was being processed and wait for another instance of the
signal. SIGDORTI causes the system to simulate a rett instruction,
which clears the mark the system placed on the stack at the point of
interrupt before checking for further signals to be presented due to
the specified change in signal actions. This allows a signal pack-
age such as sigset(3) to dismiss from interrupts cleanly removing
the old state from the stack before another instance of the inter-
rupt is presented.
After a fork(2) or vfork(2) the child inherits all signals. Exec(2)
resets all caught signals to default action; held signals remain
held and ignored signals remain ignored.
SEE ALSO
kill(1), ptrace(2), kill(2), jobs(3), sigset(3), setjmp(3), tty(4)
DIAGNOSTICS
The value BADSIG is returned if the given signal is out of range.
BUGS
The job control facilities are not available in standard version 7
UNIX. These facilities are still under development and may change
in future releases of the system as better inter-process communica-
tion facilities and support for virtual terminals become available.
The options and specifications of the job control facilities and the
supporting system calls are thus subject to change.
Because only one signal action can be changed at a time, it is not
possible to get the effect of SIGDOPAUSE for more than one signal at
a time.
NOTES (NS16000)
If func is 0 (SIG_DFL), the default action is reinstated. If func
is 1 (SIG_IGN), the signal is ignored. If func is 3 (SIG_HOLD), the
signal is held. Any other func specifies an address in the process
where an interrupt is simulated. If the high bit of func is one,
the signal is sent to the function whose address is func with the
high bit cleared with the action set to SIG_HOLD. (Thus DEFERSIG is
indicated by the high bit of a signal catch address.)
The handler routine can be declared:
Printed 11/16/83 3
SIGSYS(2J) GENIX Programmer's Manual SIGSYS(2J)
handler(signo)
Here signo is the signal name.
When a signal occurs, the kernel does not call the specified signal
handler directly. Instead, the special routine sigentry(3) is
called, as described in signal(2). However, the version of sigentry
used with sigsys is more complicated than the normal one, and must
save more state.
Printed 11/16/83 4