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