]>
Commit | Line | Data |
---|---|---|
5b2abdfb A |
1 | .\" Copyright (c) 1980, 1991, 1993 |
2 | .\" The Regents of the University of California. All rights reserved. | |
3 | .\" | |
4 | .\" Redistribution and use in source and binary forms, with or without | |
5 | .\" modification, are permitted provided that the following conditions | |
6 | .\" are met: | |
7 | .\" 1. Redistributions of source code must retain the above copyright | |
8 | .\" notice, this list of conditions and the following disclaimer. | |
9 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
10 | .\" notice, this list of conditions and the following disclaimer in the | |
11 | .\" documentation and/or other materials provided with the distribution. | |
12 | .\" 3. All advertising materials mentioning features or use of this software | |
13 | .\" must display the following acknowledgement: | |
14 | .\" This product includes software developed by the University of | |
15 | .\" California, Berkeley and its contributors. | |
16 | .\" 4. Neither the name of the University nor the names of its contributors | |
17 | .\" may be used to endorse or promote products derived from this software | |
18 | .\" without specific prior written permission. | |
19 | .\" | |
20 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
21 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
22 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
23 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
24 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
25 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
26 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
27 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
28 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
29 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
30 | .\" SUCH DAMAGE. | |
31 | .\" | |
32 | .\" @(#)sigvec.2 8.2 (Berkeley) 4/19/94 | |
33 | .\" $FreeBSD: src/lib/libc/compat-43/sigvec.2,v 1.9.2.7 2001/12/14 18:33:49 ru Exp $ | |
34 | .\" | |
35 | .Dd April 19, 1994 | |
36 | .Dt SIGVEC 2 | |
37 | .Os | |
38 | .Sh NAME | |
39 | .Nm sigvec | |
40 | .Nd software signal facilities | |
41 | .Sh LIBRARY | |
42 | .Lb libc | |
43 | .Sh SYNOPSIS | |
44 | .In signal.h | |
45 | .Bd -literal | |
46 | struct sigvec { | |
47 | void (*sv_handler)(); | |
48 | int sv_mask; | |
49 | int sv_flags; | |
50 | }; | |
51 | .Ed | |
52 | .Ft int | |
53 | .Fn sigvec "int sig" "struct sigvec *vec" "struct sigvec *ovec" | |
54 | .Sh DESCRIPTION | |
55 | .Bf -symbolic | |
56 | This interface is made obsolete by | |
57 | .Xr sigaction 2 . | |
58 | .Ef | |
59 | .Pp | |
60 | The system defines a set of signals that may be delivered to a process. | |
61 | Signal delivery resembles the occurrence of a hardware interrupt: | |
62 | the signal is blocked from further occurrence, the current process | |
63 | context is saved, and a new one is built. A process may specify a | |
64 | .Em handler | |
65 | to which a signal is delivered, or specify that a signal is to be | |
66 | .Em blocked | |
67 | or | |
68 | .Em ignored . | |
69 | A process may also specify that a default action is to be taken | |
70 | by the system when a signal occurs. | |
71 | Normally, signal handlers execute on the current stack | |
72 | of the process. This may be changed, on a per-handler basis, | |
73 | so that signals are taken on a special | |
74 | .Em "signal stack" . | |
75 | .Pp | |
76 | All signals have the same | |
77 | .Em priority . | |
78 | Signal routines execute with the signal that caused their | |
79 | invocation | |
80 | .Em blocked , | |
81 | but other signals may yet occur. | |
82 | A global | |
83 | .Em "signal mask" | |
84 | defines the set of signals currently blocked from delivery | |
85 | to a process. The signal mask for a process is initialized | |
86 | from that of its parent (normally 0). It | |
87 | may be changed with a | |
88 | .Xr sigblock 2 | |
89 | or | |
90 | .Xr sigsetmask 2 | |
91 | call, or when a signal is delivered to the process. | |
92 | .Pp | |
93 | When a signal | |
94 | condition arises for a process, the signal is added to a set of | |
95 | signals pending for the process. If the signal is not currently | |
96 | .Em blocked | |
97 | by the process then it is delivered to the process. When a signal | |
98 | is delivered, the current state of the process is saved, | |
99 | a new signal mask is calculated (as described below), | |
100 | and the signal handler is invoked. The call to the handler | |
101 | is arranged so that if the signal handling routine returns | |
102 | normally the process will resume execution in the context | |
103 | from before the signal's delivery. | |
104 | If the process wishes to resume in a different context, then it | |
105 | must arrange to restore the previous context itself. | |
106 | .Pp | |
107 | When a signal is delivered to a process a new signal mask is | |
108 | installed for the duration of the process' signal handler | |
109 | (or until a | |
110 | .Xr sigblock 2 | |
111 | or | |
112 | .Xr sigsetmask 2 | |
113 | call is made). | |
114 | This mask is formed by taking the current signal mask, | |
115 | adding the signal to be delivered, and | |
116 | .Em or Ns 'ing | |
117 | in the signal mask associated with the handler to be invoked. | |
118 | .Pp | |
119 | .Fn Sigvec | |
120 | assigns a handler for a specific signal. If | |
121 | .Fa vec | |
122 | is non-zero, it | |
123 | specifies a handler routine and mask | |
124 | to be used when delivering the specified signal. | |
125 | Further, if the | |
126 | .Dv SV_ONSTACK | |
127 | bit is set in | |
128 | .Fa sv_flags , | |
129 | the system will deliver the signal to the process on a | |
130 | .Em "signal stack" , | |
131 | specified with | |
132 | .Xr sigaltstack 2 . | |
133 | If | |
134 | .Fa ovec | |
135 | is non-zero, the previous handling information for the signal | |
136 | is returned to the user. | |
137 | .Pp | |
138 | The following is a list of all signals | |
139 | with names as in the include file | |
140 | .Aq Pa signal.h : | |
141 | .Bl -column SIGVTALARMXX "create core imagexxx" | |
142 | .It Sy "NAME Default Action Description" | |
143 | .It Dv SIGHUP No " terminate process" " terminal line hangup" | |
144 | .It Dv SIGINT No " terminate process" " interrupt program" | |
145 | .It Dv SIGQUIT No " create core image" " quit program" | |
146 | .It Dv SIGILL No " create core image" " illegal instruction" | |
147 | .It Dv SIGTRAP No " create core image" " trace trap" | |
148 | .It Dv SIGABRT No " create core image" Ta Xr abort 3 | |
149 | call (formerly | |
150 | .Dv SIGIOT ) | |
151 | .It Dv SIGEMT No " create core image" " emulate instruction executed" | |
152 | .It Dv SIGFPE No " create core image" " floating-point exception" | |
153 | .It Dv SIGKILL No " terminate process" " kill program" | |
154 | .It Dv SIGBUS No " create core image" " bus error" | |
155 | .It Dv SIGSEGV No " create core image" " segmentation violation" | |
156 | .It Dv SIGSYS No " create core image" " non-existent system call invoked" | |
157 | .It Dv SIGPIPE No " terminate process" " write on a pipe with no reader" | |
158 | .It Dv SIGALRM No " terminate process" " real-time timer expired" | |
159 | .It Dv SIGTERM No " terminate process" " software termination signal" | |
160 | .It Dv SIGURG No " discard signal" " urgent condition present on socket" | |
161 | .It Dv SIGSTOP No " stop process" " stop (cannot be caught or ignored)" | |
162 | .It Dv SIGTSTP No " stop process" " stop signal generated from keyboard" | |
163 | .It Dv SIGCONT No " discard signal" " continue after stop" | |
164 | .It Dv SIGCHLD No " discard signal" " child status has changed" | |
165 | .It Dv SIGTTIN No " stop process" " background read attempted from control terminal" | |
166 | .It Dv SIGTTOU No " stop process" " background write attempted to control terminal" | |
167 | .It Dv SIGIO No " discard signal" Tn " I/O" | |
168 | is possible on a descriptor (see | |
169 | .Xr fcntl 2 ) | |
170 | .It Dv SIGXCPU No " terminate process" " cpu time limit exceeded (see" | |
171 | .Xr setrlimit 2 ) | |
172 | .It Dv SIGXFSZ No " terminate process" " file size limit exceeded (see" | |
173 | .Xr setrlimit 2 ) | |
174 | .It Dv SIGVTALRM No " terminate process" " virtual time alarm (see" | |
175 | .Xr setitimer 2 ) | |
176 | .It Dv SIGPROF No " terminate process" " profiling timer alarm (see" | |
177 | .Xr setitimer 2 ) | |
178 | .It Dv SIGWINCH No " discard signal" " Window size change" | |
179 | .It Dv SIGINFO No " discard signal" " status request from keyboard" | |
180 | .It Dv SIGUSR1 No " terminate process" " User defined signal 1" | |
181 | .It Dv SIGUSR2 No " terminate process" " User defined signal 2" | |
182 | .El | |
183 | .Pp | |
184 | Once a signal handler is installed, it remains installed | |
185 | until another | |
186 | .Fn sigvec | |
187 | call is made, or an | |
188 | .Xr execve 2 | |
189 | is performed. | |
190 | A signal-specific default action may be reset by | |
191 | setting | |
192 | .Fa sv_handler | |
193 | to | |
194 | .Dv SIG_DFL . | |
195 | The defaults are process termination, possibly with core dump; | |
196 | no action; stopping the process; or continuing the process. | |
197 | See the above signal list for each signal's default action. | |
198 | If | |
199 | .Fa sv_handler | |
200 | is | |
201 | .Dv SIG_IGN | |
202 | current and pending instances | |
203 | of the signal are ignored and discarded. | |
204 | .Pp | |
205 | If a signal is caught during the system calls listed below, | |
206 | the call is normally restarted. | |
207 | The call can be forced to terminate prematurely with an | |
208 | .Er EINTR | |
209 | error return by setting the | |
210 | .Dv SV_INTERRUPT | |
211 | bit in | |
212 | .Fa sv_flags . | |
213 | The affected system calls include | |
214 | .Xr read 2 , | |
215 | .Xr write 2 , | |
216 | .Xr sendto 2 , | |
217 | .Xr recvfrom 2 , | |
218 | .Xr sendmsg 2 | |
219 | and | |
220 | .Xr recvmsg 2 | |
221 | on a communications channel or a slow device (such as a terminal, | |
222 | but not a regular file) | |
223 | and during a | |
224 | .Xr wait 2 | |
225 | or | |
226 | .Xr ioctl 2 . | |
227 | However, calls that have already committed are not restarted, | |
228 | but instead return a partial success (for example, a short read count). | |
229 | .Pp | |
230 | After a | |
231 | .Xr fork 2 | |
232 | or | |
233 | .Xr vfork 2 | |
234 | all signals, the signal mask, the signal stack, | |
235 | and the restart/interrupt flags are inherited by the child. | |
236 | .Pp | |
237 | .Xr Execve 2 | |
238 | reinstates the default | |
239 | action for all signals which were caught and | |
240 | resets all signals to be caught on the user stack. | |
241 | Ignored signals remain ignored; | |
242 | the signal mask remains the same; | |
243 | signals that interrupt system calls continue to do so. | |
244 | .Sh NOTES | |
245 | The mask specified in | |
246 | .Fa vec | |
247 | is not allowed to block | |
248 | .Dv SIGKILL | |
249 | or | |
250 | .Dv SIGSTOP . | |
251 | This is done silently by the system. | |
252 | .Pp | |
253 | The | |
254 | .Dv SV_INTERRUPT | |
255 | flag is not available in | |
256 | .Bx 4.2 , | |
257 | hence it should not be used if backward compatibility is needed. | |
258 | .Sh RETURN VALUES | |
259 | .Rv -std sigvec | |
260 | .Sh ERRORS | |
261 | .Fn Sigvec | |
262 | will fail and no new signal handler will be installed if one | |
263 | of the following occurs: | |
264 | .Bl -tag -width Er | |
265 | .It Bq Er EFAULT | |
266 | Either | |
267 | .Fa vec | |
268 | or | |
269 | .Fa ovec | |
270 | points to memory that is not a valid part of the process | |
271 | address space. | |
272 | .It Bq Er EINVAL | |
273 | .Fa Sig | |
274 | is not a valid signal number. | |
275 | .It Bq Er EINVAL | |
276 | An attempt is made to ignore or supply a handler for | |
277 | .Dv SIGKILL | |
278 | or | |
279 | .Dv SIGSTOP . | |
280 | .El | |
281 | .Sh SEE ALSO | |
282 | .Xr kill 1 , | |
283 | .Xr kill 2 , | |
284 | .Xr ptrace 2 , | |
285 | .Xr sigaction 2 , | |
286 | .Xr sigaltstack 2 , | |
287 | .Xr sigblock 2 , | |
288 | .Xr sigpause 2 , | |
289 | .Xr sigprocmask 2 , | |
290 | .Xr sigsetmask 2 , | |
291 | .Xr sigsuspend 2 , | |
292 | .Xr setjmp 3 , | |
293 | .Xr siginterrupt 3 , | |
294 | .Xr signal 3 , | |
295 | .Xr sigsetops 3 , | |
296 | .Xr tty 4 | |
297 | .Sh EXAMPLES | |
298 | On the | |
299 | .Tn VAX\-11 | |
300 | The handler routine can be declared: | |
301 | .Bd -literal -offset indent | |
302 | void handler(sig, code, scp) | |
303 | int sig, code; | |
304 | struct sigcontext *scp; | |
305 | .Ed | |
306 | .Pp | |
307 | Here | |
308 | .Fa sig | |
309 | is the signal number, into which the hardware faults and traps are | |
310 | mapped as defined below. | |
311 | .Fa Code | |
312 | is a parameter that is either a constant | |
313 | as given below or, for compatibility mode faults, the code provided by | |
314 | the hardware (Compatibility mode faults are distinguished from the | |
315 | other | |
316 | .Dv SIGILL | |
317 | traps by having | |
318 | .Dv PSL_CM | |
319 | set in the psl). | |
320 | .Fa Scp | |
321 | is a pointer to the | |
322 | .Fa sigcontext | |
323 | structure (defined in | |
324 | .Aq Pa signal.h ) , | |
325 | used to restore the context from before the signal. | |
326 | .Sh BUGS | |
327 | This manual page is still confusing. |