SIGSYS(2) — System Interface Manual — System Calls
NAME
sigsys − catch or ignore signals
SYNOPSIS
#include <signal.h>
(∗sigsys(sig, func))()
void (∗func)();
cc ... −ljobs
DESCRIPTION
In 4.2 this interface will become the standard signal interface, after slight modifications...
The routine sigsys is not normally called directly; rather the routines 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 signal(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 the SIGKILL and SIGSTOP signals 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 in the include file.
SIGHUP1hangup
SIGINT2interrupt
SIGQUIT3∗quit
SIGILL4∗illegal instruction (not reset when caught)
SIGTRAP5∗trace trap (not reset when caught)
SIGIOT6∗IOT instruction
SIGEMT7∗EMT instruction
SIGFPE8∗floating point exception
SIGKILL9kill (cannot be caught, held or ignored)
SIGBUS10∗bus error
SIGSEGV11∗segmentation violation
SIGSYS12∗bad argument to system call
SIGPIPE13write on a pipe with no one to read it
SIGALRM14alarm clock
SIGTERM15software termination signal
16unassigned
SIGSTOP17†stop (cannot be caught, held or ignored)
SIGTSTP18†stop signal generated from keyboard
SIGCONT19•continue after stop
SIGCHLD20•child status has changed
SIGTTIN21†background read attempted from control terminal
SIGTTOU22†background write attempted to control terminal
SIGTINT23•input record is available at control terminal
SIGXCPU24cpu time limit exceeded (see vlimit(2))
SIGXFSZ25file size limit exceeded (see vlimit(2))
SIGWINCH26•window changed (see window(4))
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 † stop the process. If func is SIG_HOLD the signal is remembered if it occurs, but 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 (that is, if the action was previously 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 recursive 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 or write(2) on a slow device (like a terminal; but not a file) and during a pause 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 takes place, it will appear that the system call returned an error status. The user’s program may then, if it wishes, re-execute the call. Read and write calls which have done no I/O, ioctls blocked with SIGTTOU, and wait3 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 oring bits into the signal number: SIGDOPAUSE causes the process to pause after changing the signal action. It can be used to atomically re-enable a held signal which was being processed and wait for another instance of the signal. SIGDORTI causes the system to simulate an rei instruction clearing 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 package such as sigset(3) to dismiss from interrupts cleanly removing the old state from the stack before another instance of the interrupt 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.
RETURN VALUE
The value BADSIG is returned if the given signal is out of range.
SEE ALSO
kill(1), ptrace(2), kill(2), jobs(3), sigset(3), setjmp(3), tty(4)
BUGS
Since 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.
The traps (listed below) should be distinguishable by extra arguments to the signal handler, and all hardware supplied parameters should be made available to the signal routine.
NOTES (SUN)
The handler routine can be declared:
handler(signo, d0, d1, a0, a1, frame)
struct frame {
int signo;
int (∗func) ();
short sr;
int pc; } frame;
Here signo is the signal name, into which the hardware faults and traps are mapped as defined below. The parameters d0, d1, a0, and a1 are the saved C scratch registers.
After return from the signal handler the pc and sr are popped off of the stack with an rte, so they act as “value-result” parameters unlike normal C value parameters. The saved registers are also value-result.
The following defines the mapping of hardware traps to signals and codes. All of these symbols are defined in <signal.h>:
Hardware conditionSignal
Arithmetic traps:
Integer division by zeroSIGFPE
CHK InstructionSIGFPE
TRAPV InstructionSIGFPE
User bus errorSIGSEGV
Address errorSIGBUS
Line 1010 emulator trap.SIGEMT
Line 1111 emulator trap.SIGEMT
Privileged instructionSIGILL
Illegal instructionSIGILL
Undefined trapSIGILL
Trace trap or ASTSIGTRAP
Breakpoint instructionSIGTRAP
NOTES (VAX-11)
The handler routine can be declared:
handler(signo, param, xx, pc, psl)
Here signo is the signal name, into which the hardware faults and traps are mapped as defined below. Param is the parameter which is either a constant as given below or, for compatibility mode faults, the code provided by the hardware. Compatibility mode faults are distinguished from the other SIGILL traps by having PSL_CM set in the psl.
The routine is actually called with only 3 parameters specified in the calls or callg instruction. After return from the signal handler the pc and psl are popped off of the stack with an rei, so they act as “value-result” parameters unlike normal C value parameters.
The following defines the mapping of hardware traps to signals and codes. All of these symbols are defined in <signal.h>:
Hardware conditionSignalCode
Arithmetic traps:
Integer overflowSIGFPEFPE_INTOVF_TRAP
Integer division by zeroSIGFPEFPE_INTDIV_TRAP
Floating overflow trapSIGFPEFPE_FLTOVF_TRAP
Floating/decimal division by zeroSIGFPEFPE_FLTDIV_TRAP
Floating underflow trapSIGFPEFPE_FLTUND_TRAP
Decimal overflow trapSIGFPEFPE_DECOVF_TRAP
Subscript-rangeSIGFPEFPE_SUBRNG_TRAP
Floating overflow faultSIGFPEFPE_FLTOVF_FAULT
Floating divide by zero faultSIGFPEFPE_FLTDIV_FAULT
Floating underflow faultSIGFPEFPE_FLTUND_FAULT
Length access controlSIGSEGV
Protection violationSIGBUS
Reserved instructionSIGILLILL_RESAD_FAULT
Customer-reserved instr.SIGEMT
Reserved operandSIGILLILL_PRIVIN_FAULT
Reserved addressingSIGILLILL_RESOP_FAULT
Trace pendingSIGTRAP
Bpt instructionSIGTRAP
Compatibility-modeSIGILLhardware supplied code
ChmeSIGSEGV
ChmsSIGSEGV
ChmuSIGSEGV
Sun System Release 0.3 — 25 April 1983