blob: f7dbf9d88ebbfd53fa97f6943983d76c5ccc5a63 (
plain)
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
|
@node Signals
@chapter Signal Handling (@file{signal.h})
A @dfn{signal} is an event that interrupts the normal flow of control
in your program. Your operating environment normally defines the full
set of signals available (see @file{sys/signal.h}), as well as the
default means of dealing with them---typically, either printing an
error message and aborting your program, or ignoring the signal.
All systems support at least the following signals:
@table @code
@item SIGABRT
Abnormal termination of a program; raised by the @code{abort} function.
@item SIGFPE
A domain error in arithmetic, such as overflow, or division by zero.
@item SIGILL
Attempt to execute as a function data that is not executable.
@item SIGINT
Interrupt; an interactive attention signal.
@item SIGSEGV
An attempt to access a memory location that is not available.
@item SIGTERM
A request that your program end execution.
@end table
Two functions are available for dealing with asynchronous
signals---one to allow your program to send signals to itself (this is
called @dfn{raising} a signal), and one to specify subroutines (called
@dfn{handlers} to handle particular signals that you anticipate may
occur---whether raised by your own program or the operating environment.
To support these functions, @file{signal.h} defines three macros:
@table @code
@item SIG_DFL
Used with the @code{signal} function in place of a pointer to a
handler subroutine, to select the operating environment's default
handling of a signal.
@item SIG_IGN
Used with the @code{signal} function in place of a pointer to a
handler, to ignore a particular signal.
@item SIG_ERR
Returned by the @code{signal} function in place of a pointer to a
handler, to indicate that your request to set up a handler could not
be honored for some reason.
@end table
@file{signal.h} also defines an integral type, @code{sig_atomic_t}.
This type is not used in any function declarations; it exists only to
allow your signal handlers to declare a static storage location where
they may store a signal value. (Static storage is not otherwise
reliable from signal handlers.)
@menu
* psignal:: Print a signal message to standard error
* raise:: Send a signal
* sig2str:: Translate between signal number and name
* signal:: Specify handler subroutine for a signal
@end menu
@page
@include signal/psignal.def
@page
@include signal/raise.def
@page
@include signal/sig2str.def
@page
@include signal/signal.def
|