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