SIGNAL(II) 8/5/73 SIGNAL(II) NAME signal - catch or ignore signals SYNOPSIS (signal = 48.) sys signal; sig; label (old value in r0) signal(sig, func) int (*func)( ); DESCRIPTION A signal is generated by some abnormal event, initiated ei- ther 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 re- ceiving process, but this call allows them either to be ig- nored or to cause an interrupt to a specified location. Here is the list of signals: 1 hangup 2 interrupt 3* quit 4* illegal instruction (not reset when caught) 5* trace trap (not reset when caught) 6* IOT instruction 7* EMT instruction 8* floating point exception 9 kill (cannot be caught or ignored) 10* bus error 11* segmentation violation 12* bad argument to system call 13 write on a pipe with no one to read it In the assembler call, if label is 0, the process is termi- nated when the signal occurs; this is the default action. If label is odd, the signal is ignored. Any other even la- bel 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 signal call. In C, if func is 0, the default action for signal sig (ter- mination) is reinstated. If func is 1, the signal is ig- nored. If func is non-zero and even, it is assumed to be the address of a function entry point. When the signal oc- curs, the function will be called. A return from the func- tion will continue the process at the point it was inter- rupted. As in the assembler call, signal must in general be called again to catch subsequent signals. When a caught signal occurs during certain system calls, the call terminates prematurely. In particular this can occur - 1 - SIGNAL(II) 8/5/73 SIGNAL(II) during a read or write on a slow device (like a typewriter; but not a file); and during or wait. When such a signal oc- curs, 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-exe- cute the call. The starred signals in the list above cause a core image if not caught or ignored. The value of the call is the old action defined for the sig- nal. After a fork(II) the child inherits all signals. Exec (II) resets all caught signals to default action. SEE ALSO kill(I), kill(II), ptrace(II), reset(III) 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. BUGS - 2 -