Initial import from FreeBSD RELENG_4:
[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 .\"
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 The
120 .Fn sigvec
121 function
122 assigns a handler for a specific signal.  If
123 .Fa vec
124 is non-zero, it
125 specifies a handler routine and mask
126 to be used when delivering the specified signal.
127 Further, if the
128 .Dv SV_ONSTACK
129 bit is set in
130 .Fa sv_flags ,
131 the system will deliver the signal to the process on a
132 .Em "signal stack" ,
133 specified with
134 .Xr sigaltstack 2 .
135 If
136 .Fa ovec
137 is non-zero, the previous handling information for the signal
138 is returned to the user.
139 .Pp
140 The following is a list of all signals
141 with names as in the include file
142 .Aq Pa signal.h :
143 .Bl -column SIGVTALARMXX "create core imagexxx"
144 .It Sy "NAME    Default Action  Description"
145 .It Dv SIGHUP No "      terminate process" "    terminal line hangup"
146 .It Dv SIGINT No "      terminate process" "    interrupt program"
147 .It Dv SIGQUIT No "     create core image" "    quit program"
148 .It Dv SIGILL No "      create core image" "    illegal instruction"
149 .It Dv SIGTRAP No "     create core image" "    trace trap"
150 .It Dv SIGABRT No "     create core image" Ta Xr abort 3
151 call (formerly
152 .Dv SIGIOT )
153 .It Dv SIGEMT No "      create core image" "    emulate instruction executed"
154 .It Dv SIGFPE No "      create core image" "    floating-point exception"
155 .It Dv SIGKILL No "     terminate process" "    kill program"
156 .It Dv SIGBUS No "      create core image" "    bus error"
157 .It Dv SIGSEGV No "     create core image" "    segmentation violation"
158 .It Dv SIGSYS No "      create core image" "    non-existent system call invoked"
159 .It Dv SIGPIPE No "     terminate process" "    write on a pipe with no reader"
160 .It Dv SIGALRM No "     terminate process" "    real-time timer expired"
161 .It Dv SIGTERM No "     terminate process" "    software termination signal"
162 .It Dv SIGURG No "      discard signal" "       urgent condition present on socket"
163 .It Dv SIGSTOP No "     stop process" " stop (cannot be caught or ignored)"
164 .It Dv SIGTSTP No "     stop process" " stop signal generated from keyboard"
165 .It Dv SIGCONT No "     discard signal" "       continue after stop"
166 .It Dv SIGCHLD No "     discard signal" "       child status has changed"
167 .It Dv SIGTTIN No "     stop process" " background read attempted from control terminal"
168 .It Dv SIGTTOU No "     stop process" " background write attempted to control terminal"
169 .It Dv SIGIO No "       discard signal" Tn "    I/O"
170 is possible on a descriptor (see
171 .Xr fcntl 2 )
172 .It Dv SIGXCPU No "     terminate process" "    cpu time limit exceeded (see"
173 .Xr setrlimit 2 )
174 .It Dv SIGXFSZ No "     terminate process" "    file size limit exceeded (see"
175 .Xr setrlimit 2 )
176 .It Dv SIGVTALRM No "   terminate process" "    virtual time alarm (see"
177 .Xr setitimer 2 )
178 .It Dv SIGPROF No "     terminate process" "    profiling timer alarm (see"
179 .Xr setitimer 2 )
180 .It Dv SIGWINCH No "    discard signal" "       Window size change"
181 .It Dv SIGINFO No "     discard signal" "       status request from keyboard"
182 .It Dv SIGUSR1 No "     terminate process" "    User defined signal 1"
183 .It Dv SIGUSR2 No "     terminate process" "    User defined signal 2"
184 .El
185 .Pp
186 Once a signal handler is installed, it remains installed
187 until another
188 .Fn sigvec
189 call is made, or an
190 .Xr execve 2
191 is performed.
192 A signal-specific default action may be reset by
193 setting
194 .Fa sv_handler
195 to
196 .Dv SIG_DFL .
197 The defaults are process termination, possibly with core dump;
198 no action; stopping the process; or continuing the process.
199 See the above signal list for each signal's default action.
200 If
201 .Fa sv_handler
202 is
203 .Dv SIG_IGN
204 current and pending instances
205 of the signal are ignored and discarded.
206 .Pp
207 If a signal is caught during the system calls listed below,
208 the call is normally restarted.
209 The call can be forced to terminate prematurely with an
210 .Er EINTR
211 error return by setting the
212 .Dv SV_INTERRUPT
213 bit in
214 .Fa sv_flags .
215 The affected system calls include
216 .Xr read 2 ,
217 .Xr write 2 ,
218 .Xr sendto 2 ,
219 .Xr recvfrom 2 ,
220 .Xr sendmsg 2
221 and
222 .Xr recvmsg 2
223 on a communications channel or a slow device (such as a terminal,
224 but not a regular file)
225 and during a
226 .Xr wait 2
227 or
228 .Xr ioctl 2 .
229 However, calls that have already committed are not restarted,
230 but instead return a partial success (for example, a short read count).
231 .Pp
232 After a
233 .Xr fork 2
234 or
235 .Xr vfork 2
236 all signals, the signal mask, the signal stack,
237 and the restart/interrupt flags are inherited by the child.
238 .Pp
239 The
240 .Xr execve 2
241 system call reinstates the default
242 action for all signals which were caught and
243 resets all signals to be caught on the user stack.
244 Ignored signals remain ignored;
245 the signal mask remains the same;
246 signals that interrupt system calls continue to do so.
247 .Sh NOTES
248 The mask specified in
249 .Fa vec
250 is not allowed to block
251 .Dv SIGKILL
252 or
253 .Dv SIGSTOP .
254 This is done silently by the system.
255 .Pp
256 The
257 .Dv SV_INTERRUPT
258 flag is not available in
259 .Bx 4.2 ,
260 hence it should not be used if backward compatibility is needed.
261 .Sh RETURN VALUES
262 .Rv -std sigvec
263 .Sh ERRORS
264 The
265 .Fn sigvec
266 function
267 will fail and no new signal handler will be installed if one
268 of the following occurs:
269 .Bl -tag -width Er
270 .It Bq Er EFAULT
271 Either
272 .Fa vec
273 or
274 .Fa ovec
275 points to memory that is not a valid part of the process
276 address space.
277 .It Bq Er EINVAL
278 The
279 .Fa sig
280 argument
281 is not a valid signal number.
282 .It Bq Er EINVAL
283 An attempt is made to ignore or supply a handler for
284 .Dv SIGKILL
285 or
286 .Dv SIGSTOP .
287 .El
288 .Sh SEE ALSO
289 .Xr kill 1 ,
290 .Xr kill 2 ,
291 .Xr ptrace 2 ,
292 .Xr sigaction 2 ,
293 .Xr sigaltstack 2 ,
294 .Xr sigblock 2 ,
295 .Xr sigpause 2 ,
296 .Xr sigprocmask 2 ,
297 .Xr sigsetmask 2 ,
298 .Xr sigsuspend 2 ,
299 .Xr setjmp 3 ,
300 .Xr siginterrupt 3 ,
301 .Xr signal 3 ,
302 .Xr sigsetops 3 ,
303 .Xr tty 4
304 .Sh EXAMPLES
305 On the
306 .Tn VAX\-11
307 The handler routine can be declared:
308 .Bd -literal -offset indent
309 void handler(sig, code, scp)
310 int sig, code;
311 struct sigcontext *scp;
312 .Ed
313 .Pp
314 Here
315 .Fa sig
316 is the signal number, into which the hardware faults and traps are
317 mapped as defined below.
318 The
319 .Fa code
320 argument
321 is either a constant
322 as given below or, for compatibility mode faults, the code provided by
323 the hardware (Compatibility mode faults are distinguished from the
324 other
325 .Dv SIGILL
326 traps by having
327 .Dv PSL_CM
328 set in the psl).
329 The
330 .Fa scp
331 argument
332 is a pointer to the
333 .Fa sigcontext
334 structure (defined in
335 .Aq Pa signal.h ) ,
336 used to restore the context from before the signal.
337 .Sh BUGS
338 This manual page is still confusing.