Commit | Line | Data |
---|---|---|
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 | 14 | sigvec \- 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 |
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 | |
39c5f4ce | 55 | to a process. The signal mask for a process is initialized |
524c1ac2 KM |
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. | |
a1f257a2 | 88 | .PP |
524c1ac2 KM |
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 | |
39c5f4ce KM |
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 | |
524c1ac2 KM |
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. | |
a1f257a2 | 105 | .PP |
524c1ac2 KM |
106 | The following is a list of all signals |
107 | with 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 |
112 | SIGHUP 1 hangup |
113 | SIGINT 2 interrupt | |
114 | SIGQUIT 3* quit | |
524c1ac2 KM |
115 | SIGILL 4* illegal instruction |
116 | SIGTRAP 5* trace trap | |
a1f257a2 KM |
117 | SIGIOT 6* IOT instruction |
118 | SIGEMT 7* EMT instruction | |
119 | SIGFPE 8* floating point exception | |
524c1ac2 | 120 | SIGKILL 9 kill (cannot be caught, blocked, or ignored) |
a1f257a2 KM |
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 | |
524c1ac2 KM |
127 | SIGURG 16\*b urgent condition present on socket |
128 | SIGSTOP 17\*d stop (cannot be caught, blocked, or ignored) | |
a1f257a2 | 129 | SIGTSTP 18\*d stop signal generated from keyboard |
524c1ac2 | 130 | SIGCONT 19\*b continue after stop (cannot be blocked) |
a1f257a2 KM |
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 | |
524c1ac2 KM |
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)) | |
39c5f4ce | 139 | SIGWINCH 28\*b window size change |
020ba080 KM |
140 | SIGUSR1 30 user defined signal 1 |
141 | SIGUSR2 31 user defined signal 2 | |
a1f257a2 KM |
142 | .fi |
143 | .PP | |
144 | The starred signals in the list above cause a core image | |
524c1ac2 | 145 | if not caught or ignored. |
a1f257a2 | 146 | .PP |
524c1ac2 KM |
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 | |
a1f257a2 KM |
156 | (with a core image for starred signals) |
157 | except for signals marked with \*b or \*d. | |
524c1ac2 KM |
158 | Signals marked with \*b are discarded if the action |
159 | is SIG_DFL; signals marked | |
a1f257a2 KM |
160 | with \*d cause the process to stop. |
161 | If | |
524c1ac2 | 162 | .I sv_handler |
a1f257a2 | 163 | is SIG_IGN the signal is subsequently ignored, |
524c1ac2 | 164 | and pending instances of the signal are discarded. |
a1f257a2 | 165 | .PP |
39c5f4ce KM |
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) | |
a1f257a2 KM |
173 | or |
174 | .IR write (2) | |
524c1ac2 | 175 | on a slow device (such as a terminal; but not a file) |
a1f257a2 | 176 | and during a |
a1f257a2 | 177 | .IR wait (2). |
a1f257a2 KM |
178 | .PP |
179 | After a | |
180 | .IR fork (2) | |
181 | or | |
182 | .IR vfork (2) | |
183 | the child inherits | |
39c5f4ce KM |
184 | all signals, the signal mask, the signal stack, |
185 | and the restart/interrupt flags. | |
524c1ac2 KM |
186 | .PP |
187 | .IR Execve (2) | |
a1f257a2 | 188 | resets all |
39c5f4ce KM |
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. | |
524c1ac2 KM |
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. | |
39c5f4ce KM |
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. | |
524c1ac2 KM |
202 | .SH "RETURN VALUE |
203 | A 0 value indicated that the call succeeded. A \-1 return value | |
39c5f4ce | 204 | indicates an error occurred and |
524c1ac2 KM |
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 | |
eff6446c | 217 | points to memory that is not a valid part of the process |
524c1ac2 KM |
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). | |
a1f257a2 KM |
231 | .SH "SEE ALSO" |
232 | kill(1), | |
233 | ptrace(2), kill(2), | |
39c5f4ce KM |
234 | sigblock(2), sigsetmask(2), sigpause(2), |
235 | sigstack(2), sigvec(2), setjmp(3), siginterrupt(3), tty(4) | |
524c1ac2 | 236 | .SH "NOTES (VAX-11)" |
a1f257a2 KM |
237 | The 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 |
243 | Here | |
524c1ac2 KM |
244 | .I sig |
245 | is the signal number, into which the hardware faults and traps are | |
246 | mapped as defined below. | |
247 | .I Code | |
eff6446c | 248 | is a parameter that is either a constant |
a1f257a2 | 249 | as given below or, for compatibility mode faults, the code provided by |
524c1ac2 KM |
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. | |
a1f257a2 KM |
258 | .PP |
259 | The following defines the mapping of hardware traps to signals | |
524c1ac2 KM |
260 | and 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 | ||
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 | |
524c1ac2 | 291 | .SH BUGS |
39c5f4ce | 292 | This manual page is still confusing. |