1SIGNAL(2) System Calls Manual SIGNAL(2)
2
3
4
6 signal - catch or ignore signals
7
9 #include <signal.h>
10
11 (*signal(sig, func))()
12 (*func)();
13
15 A signal is generated by some abnormal event, initiated either by user
16 at a typewriter (quit, interrupt), by a program error (bus error,
17 etc.), or by request of another program (kill). Normally all signals
18 cause termination of the receiving process, but a signal call allows
19 them either to be ignored or to cause an interrupt to a specified loca‐
20 tion. Here is the list of signals with names as in the include file.
21
22 SIGHUP 1 hangup
23 SIGINT 2 interrupt
24 SIGQUIT 3* quit
25 SIGILL 4* illegal instruction (not reset when caught)
26 SIGTRAP 5* trace trap (not reset when caught)
27 SIGIOT 6* IOT instruction
28 SIGEMT 7* EMT instruction
29 SIGFPE 8* floating point exception
30 SIGKILL 9 kill (cannot be caught or ignored)
31 SIGBUS 10* bus error
32 SIGSEGV 11* segmentation violation
33 SIGSYS 12* bad argument to system call
34 SIGPIPE 13 write on a pipe or link with no one to read it
35 SIGALRM 14 alarm clock
36 SIGTERM 15 software termination signal
37 16 unassigned
38
39 The starred signals in the list above cause a core image if not caught
40 or ignored.
41
42 If func is SIG_DFL, the default action for signal sig is reinstated;
43 this default is termination, sometimes with a core image. If func is
44 SIG_IGN the signal is ignored. Otherwise when the signal occurs func
45 will be called with the signal number as argument. A return from the
46 function will continue the process at the point it was interrupted.
47 Except as indicated, a signal is reset to SIG_DFL after being caught.
48 Thus if it is desired to catch every such signal, the catching routine
49 must issue another signal call.
50
51 When a caught signal occurs during certain system calls, the call ter‐
52 minates prematurely. In particular this can occur during a read or
53 write(2) on a slow device (like a typewriter; but not a file); and dur‐
54 ing pause or wait(2). When such a signal occurs, the saved user status
55 is arranged in such a way that when return from the signal-catching
56 takes place, it will appear that the system call returned an error sta‐
57 tus. The user's program may then, if it wishes, re-execute the call.
58
59 The value of signal is the previous (or initial) value of func for the
60 particular signal.
61
62 After a fork(2) the child inherits all signals. Exec(2) resets all
63 caught signals to default action.
64
66 kill(1), kill(2), ptrace(2), setjmp(3)
67
69 The value (int)-1 is returned if the given signal is out of range.
70
72 If a repeated signal arrives before the last one can be reset, there is
73 no chance to catch it.
74
75 The type specification of the routine and its func argument are prob‐
76 lematical.
77
79 (signal = 48.)
80 sys signal; sig; label
81 (old label in r0)
82
83 If label is 0, default action is reinstated. If label is odd, the sig‐
84 nal is ignored. Any other even label specifies an address in the
85 process where an interrupt is simulated. An RTI or RTT instruction
86 will return from the interrupt.
87
88
89
90 SIGNAL(2)