1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
|
'\" te
.\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved.
.\" Copyright (c) 1980 Regents of the University of California. All rights reserved. The Berkeley software License Agreement specifies the terms and conditions for redistribution.
.TH sigvec 3UCB "30 Oct 2007" "SunOS 5.11" "SunOS/BSD Compatibility Library Functions"
.SH NAME
sigvec \- software signal facilities
.SH SYNOPSIS
.LP
.nf
\fB/usr/ucb/cc\fR [ \fIflag\fR \&.\|.\|. ] \fIfile\fR\&.\|.\|.
#include <signal.h>
\fBint\fR \fBsigvec\fR(\fIsig\fR, \fInvec\fR, \fIovec\fR)
\fBint\fR \fIsig\fR;
\fBstruct sigvec *\fR\fInvec\fR, \fB*\fR\fIovec\fR;
.fi
.SH DESCRIPTION
.sp
.LP
The system defines a set of signals that may be delivered to a process. Signal
delivery resembles the occurrence of a hardware interrupt: the signal is
blocked from further occurrence, the current process context is saved, and a
new one is built. A process may specify a \fIhandler\fR to which a signal is
delivered, or specify that a signal is to be \fIblocked\fR or \fIignored\fR. A
process may also specify that a default action is to be taken by the system
when a signal occurs. Normally, signal handlers execute on the current stack of
the process. This may be changed, on a per-handler basis, so that signals are
taken on a special \fIsignal stack\fR.
.sp
.LP
All signals have the same \fIpriority\fR. Signal routines execute with the
signal that caused their invocation to be \fIblocked\fR, but other signals may
yet occur. A global \fIsignal mask\fR defines the set of signals currently
blocked from delivery to a process. The signal mask for a process is
initialized from that of its parent (normally 0). It may be changed with a
\fBsigblock()\fR or \fBsigsetmask()\fR call, or when a signal is delivered to
the process.
.sp
.LP
A process may also specify a set of \fIflags\fR for a signal that affect the
delivery of that signal.
.sp
.LP
When a signal condition arises for a process, the signal is added to a set of
signals pending for the process. If the signal is not currently \fIblocked\fR
by the process then it is delivered to the process. When a signal is
delivered, the current state of the process is saved, a new signal mask is
calculated (as described below), and the signal handler is invoked. The call to
the handler is arranged so that if the signal handling routine returns normally
the process will resume execution in the context from before the signal's
delivery. If the process wishes to resume in a different context, then it must
arrange to restore the previous context itself.
.sp
.LP
When a signal is delivered to a process a new signal mask is installed for the
duration of the process' signal handler (or until a \fBsigblock()\fR or
\fBsigsetmask()\fR call is made). This mask is formed by taking the current
signal mask, adding the signal to be delivered, and \fBOR\fRing in the signal
mask associated with the handler to be invoked.
.sp
.LP
The action to be taken when the signal is delivered is specified by a
\fBsigvec()\fR structure, which includes the following members:
.sp
.in +2
.nf
void (*sv_handler)(\|); /* signal handler */
int sv_mask; /* signal mask to apply */
int sv_flags; /* see signal options */
#define SV_ONSTACK /* take signal on signal stack */
#define SV_INTERRUPT /* do not restart system on signal
return */
#define SV_RESETHAND /* reset handler to SIG_DFL when
signal taken*/
.fi
.in -2
.sp
.LP
If the \fBSV_ONSTACK\fR bit is set in the flags for that signal, the system
will deliver the signal to the process on the signal stack specified with
\fBsigstack\fR(3UCB) rather than delivering the signal on the current stack.
.sp
.LP
If \fInvec\fR is not a \fINULL\fR pointer, \fBsigvec()\fR assigns the handler
specified by \fBsv_handler()\fR, the mask specified by \fBsv_mask()\fR, and the
flags specified by \fBsv_flags()\fR to the specified signal. If \fInvec\fR is
a \fINULL\fR pointer, \fBsigvec()\fR does not change the handler, mask, or
flags for the specified signal.
.sp
.LP
The mask specified in \fInvec\fR is not allowed to block \fBSIGKILL\fR,
\fBSIGSTOP\fR, or \fBSIGCONT\fR. The system enforces this restriction silently.
.sp
.LP
If \fIovec\fR is not a \fINULL\fR pointer, the handler, mask, and flags in
effect for the signal before the call to \fBsigvec()\fR are returned to the
user. A call to \fBsigvec()\fR with \fInvec\fR a \fINULL\fR pointer and
\fIovec\fR not a \fINULL\fR pointer can be used to determine the handling
information currently in effect for a signal without changing that information.
.sp
.LP
The following is a list of all signals with names as in the include file
\fB<signal.h>\fR:
.sp
.ne 2
.mk
.na
\fB\fBSIGHUP\fR\fR
.ad
.RS 13n
.rt
hangup
.RE
.sp
.ne 2
.mk
.na
\fB\fBSIGINT\fR\fR
.ad
.RS 13n
.rt
interrupt
.RE
.sp
.ne 2
.mk
.na
\fB\fBSIGQUIT\fR*\fR
.ad
.RS 13n
.rt
quit
.RE
.sp
.ne 2
.mk
.na
\fB\fBSIGILL\fR*\fR
.ad
.RS 13n
.rt
illegal instruction
.RE
.sp
.ne 2
.mk
.na
\fB\fBSIGTRAP\fR*\fR
.ad
.RS 13n
.rt
trace trap
.RE
.sp
.ne 2
.mk
.na
\fB\fBSIGABRT\fR*\fR
.ad
.RS 13n
.rt
abort (generated by \fBabort\fR(3C) routine)
.RE
.sp
.ne 2
.mk
.na
\fB\fBSIGEMT\fR*\fR
.ad
.RS 13n
.rt
emulator trap
.RE
.sp
.ne 2
.mk
.na
\fB\fBSIGFPE\fR*\fR
.ad
.RS 13n
.rt
arithmetic exception
.RE
.sp
.ne 2
.mk
.na
\fB\fBSIGKILL\fR\fR
.ad
.RS 13n
.rt
kill (cannot be caught, blocked, or ignored)
.RE
.sp
.ne 2
.mk
.na
\fB\fBSIGBUS\fR*\fR
.ad
.RS 13n
.rt
bus error
.RE
.sp
.ne 2
.mk
.na
\fB\fBSIGSEGV\fR*\fR
.ad
.RS 13n
.rt
segmentation violation
.RE
.sp
.ne 2
.mk
.na
\fB\fBSIGSYS\fR*\fR
.ad
.RS 13n
.rt
bad argument to function
.RE
.sp
.ne 2
.mk
.na
\fB\fBSIGPIPE\fR\fR
.ad
.RS 13n
.rt
write on a pipe or other socket with no one to read it
.RE
.sp
.ne 2
.mk
.na
\fB\fBSIGALRM\fR\fR
.ad
.RS 13n
.rt
alarm clock
.RE
.sp
.ne 2
.mk
.na
\fB\fBSIGTERM\fR\fR
.ad
.RS 13n
.rt
software termination signal
.RE
.sp
.ne 2
.mk
.na
\fB\fBSIGURG\fR*\fR
.ad
.RS 13n
.rt
urgent condition present on socket
.RE
.sp
.ne 2
.mk
.na
\fB\fBSIGSTOP\fR**\fR
.ad
.RS 13n
.rt
stop (cannot be caught, blocked, or ignored)
.RE
.sp
.ne 2
.mk
.na
\fB\fBSIGTSTP\fR**\fR
.ad
.RS 13n
.rt
stop signal generated from keyboard
.RE
.sp
.ne 2
.mk
.na
\fB\fBSIGCONT\fR*\fR
.ad
.RS 13n
.rt
continue after stop (cannot be blocked)
.RE
.sp
.ne 2
.mk
.na
\fB\fBSIGCHLD\fR*\fR
.ad
.RS 13n
.rt
child status has changed
.RE
.sp
.ne 2
.mk
.na
\fB\fBSIGTTIN\fR**\fR
.ad
.RS 13n
.rt
background read attempted from control terminal
.RE
.sp
.ne 2
.mk
.na
\fB\fBSIGTTOU\fR**\fR
.ad
.RS 13n
.rt
background write attempted to control terminal
.RE
.sp
.ne 2
.mk
.na
\fB\fBSIGIO\fR*\fR
.ad
.RS 13n
.rt
I/O is possible on a descriptor (see \fBfcntl\fR(2))
.RE
.sp
.ne 2
.mk
.na
\fB\fBSIGXCPU\fR\fR
.ad
.RS 13n
.rt
cpu time limit exceeded (see \fBgetrlimit\fR(2))
.RE
.sp
.ne 2
.mk
.na
\fB\fBSIGXFSZ\fR\fR
.ad
.RS 13n
.rt
file size limit exceeded (see \fBgetrlimit\fR(2))
.RE
.sp
.ne 2
.mk
.na
\fB\fBSIGVTALRM\fR\fR
.ad
.RS 13n
.rt
virtual time alarm; see \fBsetitimer()\fR on \fBgetitimer\fR(2)
.RE
.sp
.ne 2
.mk
.na
\fB\fBSIGPROF\fR\fR
.ad
.RS 13n
.rt
profiling timer alarm; see \fBsetitimer()\fR on \fBgetitimer\fR(2)
.RE
.sp
.ne 2
.mk
.na
\fB\fBSIGWINCH\fR*\fR
.ad
.RS 13n
.rt
window changed (see \fBtermio\fR(7I))
.RE
.sp
.ne 2
.mk
.na
\fB\fBSIGLOST\fR\fR
.ad
.RS 13n
.rt
resource lost (see \fBlockd\fR(1M))
.RE
.sp
.ne 2
.mk
.na
\fB\fBSIGUSR1\fR\fR
.ad
.RS 13n
.rt
user-defined signal 1
.RE
.sp
.ne 2
.mk
.na
\fB\fBSIGUSR2\fR\fR
.ad
.RS 13n
.rt
user-defined signal 2
.RE
.sp
.LP
The starred signals in the list above cause a core image if not caught or
ignored.
.sp
.LP
Once a signal handler is installed, it remains installed until another
\fBsigvec()\fR call is made, or an \fBexecve\fR(2) is performed, unless the
\fBSV_RESETHAND\fR bit is set in the flags for that signal. In that case, the
value of the handler for the caught signal will be set to \fBSIG_DFL\fR before
entering the signal-catching function, unless the signal is \fBSIGILL\fR,
\fBSIGPWR\fR, or \fBSIGTRAP\fR. Also, if this bit is set, the bit for that
signal in the signal mask will not be set; unless the signal mask associated
with that signal blocks that signal, further occurrences of that signal will
not be blocked. The \fBSV_RESETHAND\fR flag is not available in 4.2BSD, hence
it should not be used if backward compatibility is needed.
.sp
.LP
The default action for a signal may be reinstated by setting the signal's
handler to \fBSIG_DFL\fR; this default is termination except for signals marked
with * or **. Signals marked with * are discarded if the action is
\fBSIG_DFL\fR; signals marked with ** cause the process to stop. If the process
is terminated, a "core image" will be made in the current working directory of
the receiving process if the signal is one for which an asterisk appears in the
above list (see \fBcore\fR(4)).
.sp
.LP
If the handler for that signal is \fBSIG_IGN\fR, the signal is subsequently
ignored, and pending instances of the signal are discarded.
.sp
.LP
If a caught signal occurs during certain functions, the call is normally
restarted. The call can be forced to terminate prematurely with an \fBEINTR\fR
error return by setting the \fBSV_INTERRUPT\fR bit in the flags for that
signal. The \fBSV_INTERRUPT\fR flag is not available in 4.2BSD, hence it should
not be used if backward compatibility is needed. The affected functions are
\fBread\fR(2) or \fBwrite\fR(2) on a slow device (such as a terminal or pipe or
other socket, but not a file) and during a \fBwait\fR(3C).
.sp
.LP
After a \fBfork\fR(2) or \fBvfork\fR(2) the child inherits all signals, the
signal mask, the signal stack, and the restart/interrupt and
reset-signal-handler flags.
.sp
.LP
The \fBexecve\fR(2) call resets all caught signals to default action and resets
all signals to be caught on the user stack. Ignored signals remain ignored; the
signal mask remains the same; signals that interrupt functions continue to do
so.
.sp
.LP
The accuracy of \fIaddr\fR is machine dependent. For example, certain machines
may supply an address that is on the same page as the address that caused the
fault. If an appropriate \fIaddr\fR cannot be computed it will be set to
\fBSIG_NOADDR\fR.
.SH RETURN VALUES
.sp
.LP
A \fB0\fR value indicates that the call succeeded. A \fB\(mi1\fR return value
indicates that an error occurred and \fBerrno\fR is set to indicate the reason.
.SH ERRORS
.sp
.LP
\fBsigvec()\fR will fail and no new signal handler will be installed if one of
the following occurs:
.sp
.ne 2
.mk
.na
\fB\fBEFAULT\fR\fR
.ad
.RS 10n
.rt
Either \fInvec\fR or \fIovec\fR is not a \fINULL\fR pointer and points to
memory that is not a valid part of the process address space.
.RE
.sp
.ne 2
.mk
.na
\fB\fBEINVAL\fR\fR
.ad
.RS 10n
.rt
\fIsig\fR is not a valid signal number or is \fBSIGKILL\fR or \fBSIGSTOP\fR.
.RE
.SH SEE ALSO
.sp
.LP
\fBIntro\fR(2), \fBexec\fR(2), \fBfcntl\fR(2), \fBfork\fR(2),
\fBgetitimer\fR(2), \fBgetrlimit\fR(2), \fBioctl\fR(2), \fBkill\fR(2),
\fBread\fR(2), \fBumask\fR(2), \fBvfork\fR(2), \fBwrite\fR(2),
\fBptrace\fR(3C), \fBsetjmp\fR(3C) \fBsigblock\fR(3UCB), \fBsignal\fR(3C),
\fBsignal\fR(3UCB), \fBsigstack\fR(3UCB), \fBwait\fR(3C), \fBwait\fR(3UCB),
\fBcore\fR(4), \fBstreamio\fR(7I), \fBtermio\fR(7I)
.SH NOTES
.sp
.LP
Use of these interfaces should be restricted to only applications written on
BSD platforms. Use of these interfaces with any of the system libraries or in
multi-thread applications is unsupported.
.sp
.LP
\fBSIGPOLL\fR is a synonym for \fBSIGIO\fR. A \fBSIGIO\fR will be issued when a
file descriptor corresponding to a \fBSTREAMS\fR (see \fBIntro\fR(2)) file has
a "selectable" event pending. Unless that descriptor has been put into
asynchronous mode (see \fBfcntl\fR(2)), a process may specifically request that
this signal be sent using the \fBI_SETSIG\fR \fBioctl\fR(2) call (see
\fBstreamio\fR(7I)). Otherwise, the process will never receive \fBSIGPOLLs0\fR.
.sp
.LP
The handler routine can be declared:
.sp
.in +2
.nf
void handler(int sig, int code, struct sigcontext *scp,
char *addr);
.fi
.in -2
.sp
.LP
Here \fIsig\fR is the signal number; \fIcode\fR is a parameter of certain
signals that provides additional detail; \fIscp\fR is a pointer to the
\fBsigcontext\fR structure (defined in \fBsignal.h\fR), used to restore the
context from before the signal; and \fIaddr\fR is additional address
information.
.sp
.LP
The signals \fBSIGKILL\fR, \fBSIGSTOP\fR, and \fBSIGCONT\fR cannot be ignored.
|