restructuring libc
[unix-history] / usr / src / lib / libc / compat-43 / sigvec.2
CommitLineData
a1f257a2
KM
1.\" Copyright (c) 1980 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
020ba080 5.\" @(#)sigvec.2 6.3 (Berkeley) %G%
a1f257a2 6.\"
39c5f4ce 7.TH SIGVEC 2 ""
a1f257a2
KM
8.UC 4
9.ie t .ds d \(dg
10.el .ds d \z'|+'
11.ie t .ds b \(bu
12.el .ds b @
13.SH NAME
524c1ac2 14sigvec \- software signal facilities
a1f257a2
KM
15.SH SYNOPSIS
16.nf
17.B #include <signal.h>
18.PP
524c1ac2
KM
19.B struct sigvec {
20.B int (*sv_handler)();
21.B int sv_mask;
39c5f4ce 22.B int sv_flags;
524c1ac2 23.B };
a1f257a2 24.PP
524c1ac2
KM
25.B sigvec(sig, vec, ovec)
26.B int sig;
27.B struct sigvec *vec, *ovec;
a1f257a2
KM
28.fi
29.SH DESCRIPTION
524c1ac2
KM
30The system defines a set of signals that may be delivered to a process.
31Signal delivery resembles the occurence of a hardware interrupt:
32the signal is blocked from further occurrence, the current process
33context is saved, and a new one is built. A process may specify a
34.I handler
35to which a signal is delivered, or specify that a signal is to be
36.I blocked
37or
38.IR ignored .
39A process may also specify that a default action is to be taken
40by the system when a signal occurs.
41Normally, signal handlers execute on the current stack
42of the process. This may be changed, on a per-handler basis,
43so that signals are taken on a special
44.IR "signal stack" .
45.PP
46All signals have the same
47.IR priority .
48Signal routines execute with the signal that caused their
49invocation
50.IR blocked ,
51but other signals may yet occur.
52A global
53.I "signal mask"
54defines the set of signals currently blocked from delivery
39c5f4ce 55to a process. The signal mask for a process is initialized
524c1ac2
KM
56from that of its parent (normally 0). It
57may be changed with a
58.IR sigblock (2)
59or
60.IR sigsetmask (2)
61call, or when a signal is delivered to the process.
62.PP
63When a signal
64condition arises for a process, the signal is added to a set of
65signals pending for the process. If the signal is not currently
66.I blocked
67by the process then it is delivered to the process. When a signal
68is delivered, the current state of the process is saved,
69a new signal mask is calculated (as described below),
70and the signal handler is invoked. The call to the handler
71is arranged so that if the signal handling routine returns
72normally the process will resume execution in the context
73from before the signal's delivery.
74If the process wishes to resume in a different context, then it
75must arrange to restore the previous context itself.
76.PP
77When a signal is delivered to a process a new signal mask is
78installed for the duration of the process' signal handler
79(or until a
80.I sigblock
81or
82.I sigsetmask
83call is made).
84This mask is formed by taking the current signal mask,
85adding the signal to be delivered, and
86.IR or 'ing
87in the signal mask associated with the handler to be invoked.
a1f257a2 88.PP
524c1ac2
KM
89.I Sigvec
90assigns a handler for a specific signal. If
91.I vec
92is non-zero, it
93specifies a handler routine and mask
39c5f4ce
KM
94to be used when delivering the specified signal.
95Further, if the SV_ONSTACK bit is set in
96.I sv_flags,
97the system will deliver the signal to the process on a
524c1ac2
KM
98.IR "signal stack" ,
99specified with
100.IR sigstack (2).
101If
102.I ovec
103is non-zero, the previous handling information for the signal
104is returned to the user.
a1f257a2 105.PP
524c1ac2
KM
106The following is a list of all signals
107with names as in the include file
108.RI < signal.h >:
a1f257a2
KM
109.LP
110.nf
524c1ac2 111.ta \w'SIGVTALRM 'u +\w'15* 'u
a1f257a2
KM
112SIGHUP 1 hangup
113SIGINT 2 interrupt
114SIGQUIT 3* quit
524c1ac2
KM
115SIGILL 4* illegal instruction
116SIGTRAP 5* trace trap
a1f257a2
KM
117SIGIOT 6* IOT instruction
118SIGEMT 7* EMT instruction
119SIGFPE 8* floating point exception
524c1ac2 120SIGKILL 9 kill (cannot be caught, blocked, or ignored)
a1f257a2
KM
121SIGBUS 10* bus error
122SIGSEGV 11* segmentation violation
123SIGSYS 12* bad argument to system call
124SIGPIPE 13 write on a pipe with no one to read it
125SIGALRM 14 alarm clock
126SIGTERM 15 software termination signal
524c1ac2
KM
127SIGURG 16\*b urgent condition present on socket
128SIGSTOP 17\*d stop (cannot be caught, blocked, or ignored)
a1f257a2 129SIGTSTP 18\*d stop signal generated from keyboard
524c1ac2 130SIGCONT 19\*b continue after stop (cannot be blocked)
a1f257a2
KM
131SIGCHLD 20\*b child status has changed
132SIGTTIN 21\*d background read attempted from control terminal
133SIGTTOU 22\*d background write attempted to control terminal
524c1ac2
KM
134SIGIO 23\*b i/o is possible on a descriptor (see \fIfcntl\fP(2))
135SIGXCPU 24 cpu time limit exceeded (see \fIsetrlimit\fP(2))
136SIGXFSZ 25 file size limit exceeded (see \fIsetrlimit\fP(2))
137SIGVTALRM 26 virtual time alarm (see \fIsetitimer\fP(2))
138SIGPROF 27 profiling timer alarm (see \fIsetitimer\fP(2))
39c5f4ce 139SIGWINCH 28\*b window size change
020ba080
KM
140SIGUSR1 30 user defined signal 1
141SIGUSR2 31 user defined signal 2
a1f257a2
KM
142.fi
143.PP
144The starred signals in the list above cause a core image
524c1ac2 145if not caught or ignored.
a1f257a2 146.PP
524c1ac2
KM
147Once a signal handler is installed, it remains installed
148until another
149.I sigvec
150call is made, or an
151.IR execve (2)
152is performed.
153The default action for a signal may be reinstated by setting
154.I sv_handler
155to SIG_DFL; this default is termination
a1f257a2
KM
156(with a core image for starred signals)
157except for signals marked with \*b or \*d.
524c1ac2
KM
158Signals marked with \*b are discarded if the action
159is SIG_DFL; signals marked
a1f257a2
KM
160with \*d cause the process to stop.
161If
524c1ac2 162.I sv_handler
a1f257a2 163is SIG_IGN the signal is subsequently ignored,
524c1ac2 164and pending instances of the signal are discarded.
a1f257a2 165.PP
39c5f4ce
KM
166If a caught signal occurs during certain system calls,
167the call is normally restarted.
168The call can be forced to terminate prematurely with an
169EINTR error return by setting the SV_INTERRUPT bit in
170.I sv_flags.
171The affected system calls are
172.IR read (2)
a1f257a2
KM
173or
174.IR write (2)
524c1ac2 175on a slow device (such as a terminal; but not a file)
a1f257a2 176and during a
a1f257a2 177.IR wait (2).
a1f257a2
KM
178.PP
179After a
180.IR fork (2)
181or
182.IR vfork (2)
183the child inherits
39c5f4ce
KM
184all signals, the signal mask, the signal stack,
185and the restart/interrupt flags.
524c1ac2
KM
186.PP
187.IR Execve (2)
a1f257a2 188resets all
39c5f4ce
KM
189caught signals to default action and
190resets all signals to be caught on the user stack.
191Ignored signals remain ignored;
192the signal mask remains the same;
193signals that interrupt system calls continue to do so.
524c1ac2
KM
194.SH NOTES
195The mask specified in
196.I vec
197is not allowed to block SIGKILL, SIGSTOP, or SIGCONT. This
198is done silently by the system.
39c5f4ce
KM
199.PP
200The SV_INTERRUPT flag is not available in 4.2BSD,
201hence it should not be used if backward compatibility is needed.
524c1ac2
KM
202.SH "RETURN VALUE
203A 0 value indicated that the call succeeded. A \-1 return value
39c5f4ce 204indicates an error occurred and
524c1ac2
KM
205.I errno
206is set to indicated the reason.
207.SH ERRORS
208.I Sigvec
209will fail and no new signal handler will be installed if one
210of the following occurs:
211.TP 15
212[EFAULT]
213Either
214.I vec
215or
216.I ovec
eff6446c 217points to memory that is not a valid part of the process
524c1ac2
KM
218address space.
219.TP 15
220[EINVAL]
221.I Sig
222is not a valid signal number.
223.TP 15
224[EINVAL]
225An attempt is made to ignore or supply a handler for SIGKILL
226or SIGSTOP.
227.TP 15
228[EINVAL]
229An attempt is made to ignore SIGCONT (by default SIGCONT
230is ignored).
a1f257a2
KM
231.SH "SEE ALSO"
232kill(1),
233ptrace(2), kill(2),
39c5f4ce
KM
234sigblock(2), sigsetmask(2), sigpause(2),
235sigstack(2), sigvec(2), setjmp(3), siginterrupt(3), tty(4)
524c1ac2 236.SH "NOTES (VAX-11)"
a1f257a2
KM
237The handler routine can be declared:
238.PP
524c1ac2
KM
239 handler(sig, code, scp)
240 int sig, code;
241 struct sigcontext *scp;
a1f257a2
KM
242.PP
243Here
524c1ac2
KM
244.I sig
245is the signal number, into which the hardware faults and traps are
246mapped as defined below.
247.I Code
eff6446c 248is a parameter that is either a constant
a1f257a2 249as given below or, for compatibility mode faults, the code provided by
524c1ac2
KM
250the hardware (Compatibility mode faults are distinguished from the
251other SIGILL traps by having PSL_CM set in the psl).
252.I Scp
253is a pointer to the
254.I sigcontext
255structure (defined in
256.RI < signal.h >),
257used to restore the context from before the signal.
a1f257a2
KM
258.PP
259The following defines the mapping of hardware traps to signals
524c1ac2
KM
260and codes. All of these symbols are defined in
261.RI < signal.h >:
a1f257a2
KM
262.LP
263.ta \w' Floating/decimal divide by zero 'u +\w'15* 'u +8n
264.nf
265 Hardware condition Signal Code
266
267Arithmetic traps:
268 Integer overflow SIGFPE FPE_INTOVF_TRAP
269 Integer division by zero SIGFPE FPE_INTDIV_TRAP
270 Floating overflow trap SIGFPE FPE_FLTOVF_TRAP
271 Floating/decimal division by zero SIGFPE FPE_FLTDIV_TRAP
272 Floating underflow trap SIGFPE FPE_FLTUND_TRAP
273 Decimal overflow trap SIGFPE FPE_DECOVF_TRAP
274 Subscript-range SIGFPE FPE_SUBRNG_TRAP
275 Floating overflow fault SIGFPE FPE_FLTOVF_FAULT
276 Floating divide by zero fault SIGFPE FPE_FLTDIV_FAULT
277 Floating underflow fault SIGFPE FPE_FLTUND_FAULT
278Length access control SIGSEGV
279Protection violation SIGBUS
280Reserved instruction SIGILL ILL_RESAD_FAULT
281Customer-reserved instr. SIGEMT
282Reserved operand SIGILL ILL_PRIVIN_FAULT
283Reserved addressing SIGILL ILL_RESOP_FAULT
284Trace pending SIGTRAP
285Bpt instruction SIGTRAP
286Compatibility-mode SIGILL hardware supplied code
287Chme SIGSEGV
288Chms SIGSEGV
289Chmu SIGSEGV
290.fi
524c1ac2 291.SH BUGS
39c5f4ce 292This manual page is still confusing.