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