Commit | Line | Data |
---|---|---|
9d335a2c KM |
1 | .\" Copyright (c) 1980 Regents of the University of California. |
2 | .\" All rights reserved. The Berkeley software License Agreement | |
3 | .\" specifies the terms and conditions for redistribution. | |
4 | .\" | |
5 | .\" @(#)signal.3 4.1 (Berkeley) %G% | |
6 | .\" | |
7 | .TH SIGNAL 2 | |
8 | .UC 4 | |
9 | .SH NAME | |
10 | signal \- catch or ignore signals | |
11 | .SH SYNOPSIS | |
12 | .nf | |
13 | .B #include <signal.h> | |
14 | .PP | |
15 | .B (*signal(sig, func))() | |
16 | .B void (*func)(); | |
17 | .fi | |
18 | .SH DESCRIPTION | |
19 | .IR N.B. : | |
20 | The system currently supports two signal implementations. | |
21 | The one described here is standard in version 7 UNIX systems, | |
22 | and is retained for backward compatabililty. | |
23 | The one described in | |
24 | .IR sigsys (2) | |
25 | as supplemented by | |
26 | .IR sigset (3) | |
27 | provides for the needs of the job control mechanisms | |
28 | used by | |
29 | .IR csh (1), | |
30 | and corrects the bugs in this older implementation of signals, | |
31 | allowing programs | |
32 | which process interrupts | |
33 | to be written | |
34 | reliably. | |
35 | .PP | |
36 | A signal | |
37 | is generated by some abnormal event, | |
38 | initiated either by user at a terminal (quit, interrupt), | |
39 | by a program error (bus error, etc.), | |
40 | or by request of another program (kill). | |
41 | Normally all signals | |
42 | cause termination of the receiving process, | |
43 | but a | |
44 | .I signal | |
45 | call allows them either to be ignored | |
46 | or to cause an interrupt to a specified location. | |
47 | Here is the list of signals with names as in | |
48 | the include file. | |
49 | .LP | |
50 | .nf | |
51 | .ta \w'SIGMMMM 'u +\w'15* 'u | |
52 | SIGHUP 1 hangup | |
53 | SIGINT 2 interrupt | |
54 | SIGQUIT 3* quit | |
55 | SIGILL 4* illegal instruction (not reset when caught) | |
56 | SIGTRAP 5* trace trap (not reset when caught) | |
57 | SIGIOT 6* IOT instruction | |
58 | SIGEMT 7* EMT instruction | |
59 | SIGFPE 8* floating point exception | |
60 | SIGKILL 9 kill (cannot be caught or ignored) | |
61 | SIGBUS 10* bus error | |
62 | SIGSEGV 11* segmentation violation | |
63 | SIGSYS 12* bad argument to system call | |
64 | SIGPIPE 13 write on a pipe with no one to read it | |
65 | SIGALRM 14 alarm clock | |
66 | SIGTERM 15 software termination signal | |
67 | 16 unassigned | |
68 | .fi | |
69 | .IR N.B. : | |
70 | There are actually more signals; see | |
71 | .IR sigsys (2); | |
72 | the signals listed here are those of standard version 7. | |
73 | .PP | |
74 | The starred signals in the list above cause a core image | |
75 | if not caught or ignored. | |
76 | .PP | |
77 | If | |
78 | .I func | |
79 | is SIG_DFL, the default action | |
80 | for signal | |
81 | .I sig | |
82 | is reinstated; this default is termination, | |
83 | sometimes with a core image. | |
84 | If | |
85 | .I func | |
86 | is SIG_IGN the signal is ignored. | |
87 | Otherwise | |
88 | when the signal occurs | |
89 | .I func | |
90 | will be called with the | |
91 | signal number as argument. | |
92 | A return from the function will | |
93 | continue the process at the point it was interrupted. | |
94 | .PP | |
95 | Except as indicated, | |
96 | a signal is reset to SIG_DFL after being caught. | |
97 | Thus if it is desired to | |
98 | catch every such signal, | |
99 | the catching routine must | |
100 | issue another | |
101 | .I signal | |
102 | call. | |
103 | .PP | |
104 | If, when using this (older) signal interface, | |
105 | a caught signal occurs | |
106 | during certain system calls, the call terminates prematurely. | |
107 | In particular this can occur | |
108 | during an | |
109 | .IR ioctl , | |
110 | .IR read , | |
111 | or | |
112 | .IR write (2) | |
113 | on a slow device (like a terminal; but not a file); | |
114 | and during | |
115 | .I pause | |
116 | or | |
117 | .IR wait (2). | |
118 | When such a signal occurs, the saved user status | |
119 | is arranged in such a way that when return from the | |
120 | signal-catching takes place, it will appear that the | |
121 | system call returned an error status. | |
122 | The user's program may then, if it wishes, | |
123 | re-execute the call. | |
124 | .PP | |
125 | The value of | |
126 | .I signal | |
127 | is the previous (or initial) | |
128 | value of | |
129 | .I func | |
130 | for the particular signal. | |
131 | .PP | |
132 | After a | |
133 | .IR fork (2) | |
134 | the child inherits | |
135 | all signals. | |
136 | .IR Exec (2) | |
137 | resets all | |
138 | caught signals to default action. | |
139 | .PP | |
140 | If a process is using the mechanisms of | |
141 | .IR sigsys (2) | |
142 | and | |
143 | .IR sigset (3) | |
144 | then many of these calls are automatically restarted | |
145 | (See | |
146 | .IR sigsys (2) | |
147 | and | |
148 | .IR jobs (3) | |
149 | for details). | |
150 | .SH "SEE ALSO" | |
151 | sigsys(2), | |
152 | kill(1), | |
153 | kill(2), | |
154 | ptrace(2), | |
155 | setjmp(3), | |
156 | sigset(3) | |
157 | .SH DIAGNOSTICS | |
158 | The value (int)\-1 is returned if the | |
159 | given signal is out of range. | |
160 | .SH BUGS | |
161 | The traps should be distinguishable by extra arguments | |
162 | to the signal handler, and all hardware supplied parameters should | |
163 | be made available to the signal routine. | |
164 | .PP | |
165 | If a repeated signal arrives before the last one can be | |
166 | reset, there is no chance to catch it | |
167 | (however this is | |
168 | .B not | |
169 | true if you use | |
170 | .IR sigsys (2) | |
171 | and | |
172 | .IR sigset (3)). | |
173 | .PP | |
174 | The type specification of the routine and its | |
175 | .I func | |
176 | argument are problematical. | |
177 | .SH "ASSEMBLER (PDP-11)" | |
178 | (signal = 48.) | |
179 | .br | |
180 | .B sys signal; sig; label | |
181 | .br | |
182 | (old label in r0) | |
183 | .PP | |
184 | If | |
185 | .I label | |
186 | is 0, | |
187 | default action is reinstated. | |
188 | If | |
189 | .I label | |
190 | is 1, the signal is ignored. | |
191 | Any other even | |
192 | .I label | |
193 | specifies an address in the process | |
194 | where an interrupt is simulated. | |
195 | An RTI or RTT instruction will return from the | |
196 | interrupt. | |
197 | .SH "NOTES (VAX-11)" | |
198 | See | |
199 | .IR sigsys (2) | |
200 | for information on how hardware faults are mapped into signals. |