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