Commit | Line | Data |
---|---|---|
e6817382 BJ |
1 | .TH SIGNAL 2 |
2 | .SH NAME | |
3 | signal \- catch or ignore signals | |
4 | .SH SYNOPSIS | |
5 | .B #include <signal.h> | |
6 | .PP | |
7 | .B (*signal(sig, func))(); | |
8 | .br | |
9 | .B (*func)(); | |
10 | .SH DESCRIPTION | |
11 | A signal | |
12 | is generated by some abnormal event, | |
13 | initiated either by user at a terminal (quit, interrupt), | |
14 | by a program error (bus error, etc.), | |
15 | or by request of another program (kill). | |
16 | Normally all signals | |
17 | cause termination of the receiving process, | |
18 | but a | |
19 | .I signal | |
20 | call allows them either to be ignored | |
21 | or to cause an interrupt to a specified location. | |
22 | Here is the list of signals with names as in | |
23 | the include file. | |
24 | .LP | |
25 | .nf | |
26 | .ta \w'SIGMMMM 'u +\w'15* 'u | |
27 | SIGHUP 1 hangup | |
28 | SIGINT 2 interrupt | |
29 | SIGQUIT 3* quit | |
30 | SIGILL 4* illegal instruction (not reset when caught) | |
31 | SIGTRAP 5* trace trap (not reset when caught) | |
32 | SIGIOT 6* IOT instruction | |
33 | SIGEMT 7* EMT instruction | |
34 | SIGFPE 8* floating point exception | |
35 | SIGKILL 9 kill (cannot be caught or ignored) | |
36 | SIGBUS 10* bus error | |
37 | SIGSEGV 11* segmentation violation | |
38 | SIGSYS 12* bad argument to system call | |
39 | SIGPIPE 13 write on a pipe with no one to read it | |
40 | SIGALRM 14 alarm clock | |
41 | SIGTERM 15 software termination signal | |
42 | 16 unassigned | |
43 | .fi | |
44 | .PP | |
45 | The starred signals in the list above cause a core image | |
46 | if not caught or ignored. | |
47 | .PP | |
48 | If | |
49 | .I func | |
50 | is SIG_DFL, the default action | |
51 | for signal | |
52 | .I sig | |
53 | is reinstated; this default is termination, | |
54 | sometimes with a core image. | |
55 | If | |
56 | .I func | |
57 | is SIG_IGN the signal is ignored. | |
58 | Otherwise | |
59 | when the signal occurs | |
60 | .I func | |
61 | will be called with the | |
62 | signal number as argument. | |
63 | A return from the function will | |
64 | continue the process at the point it was interrupted. | |
65 | Except as indicated, | |
66 | a signal is reset to SIG_DFL after being caught. | |
67 | Thus if it is desired to | |
68 | catch every such signal, | |
69 | the catching routine must | |
70 | issue another | |
71 | .I signal | |
72 | call. | |
73 | .PP | |
74 | When a caught signal occurs | |
75 | during certain system calls, the call terminates prematurely. | |
76 | In particular this can occur | |
77 | during a | |
78 | .I read | |
79 | or | |
80 | .IR write (2) | |
81 | on a slow device (like a terminal; but not a file); | |
82 | and during | |
83 | .I pause | |
84 | or | |
85 | .IR wait (2). | |
86 | When such a signal occurs, the saved user status | |
87 | is arranged in such a way that when return from the | |
88 | signal-catching takes place, it will appear that the | |
89 | system call returned an error status. | |
90 | The user's program may then, if it wishes, | |
91 | re-execute the call. | |
92 | .PP | |
93 | The value of | |
94 | .I signal | |
95 | is the previous (or initial) | |
96 | value of | |
97 | .I func | |
98 | for the particular signal. | |
99 | .PP | |
100 | After a | |
101 | .IR fork (2) | |
102 | the child inherits | |
103 | all signals. | |
104 | .IR Exec (2) | |
105 | resets all | |
106 | caught signals to default action. | |
107 | .SH "SEE ALSO" | |
108 | kill(1), kill(2), | |
109 | ptrace(2), | |
110 | setjmp(3) | |
111 | .SH DIAGNOSTICS | |
112 | The value (int)\-1 is returned if the | |
113 | given signal is out of range. | |
114 | .SH BUGS | |
115 | If a repeated signal arrives before the last one can be | |
116 | reset, there is no chance to catch it. | |
117 | .PP | |
118 | The type specification of the routine and its | |
119 | .I func | |
120 | argument are problematical. | |
121 | .PP | |
122 | On the VAX-11, odd values for | |
123 | .I func | |
124 | are the same as SIG_IGN. | |
125 | .SH "ASSEMBLER (PDP-11)" | |
126 | (signal = 48.) | |
127 | .br | |
128 | .B sys signal; sig; label | |
129 | .br | |
130 | (old label in r0) | |
131 | .PP | |
132 | If | |
133 | .I label | |
134 | is 0, | |
135 | default action is reinstated. | |
136 | If | |
137 | .I label | |
138 | is odd, the signal is ignored. | |
139 | Any other even | |
140 | .I label | |
141 | specifies an address in the process | |
142 | where an interrupt is simulated. | |
143 | An RTI or RTT instruction will return from the | |
144 | interrupt. | |
145 | .SH "NOTES (VAX-11)" | |
146 | The following defines the mapping of hardware traps to signals: | |
147 | .PP | |
148 | .nf | |
149 | .ta \w' Floating divide by zero 'u +\w'15* 'u | |
150 | Arithemetic traps: | |
151 | .in +5 | |
152 | Integer overflow SIGFPE | |
153 | Integer division by zero SIGFPE | |
154 | Floating overflow SIGFPE | |
155 | Floating underflow SIGFPE | |
156 | Floating division by zero SIGFPE | |
157 | Decimal division by zero SIGFPE | |
158 | Decimal overflow SIGFPE | |
159 | Subscript-range SIGFPE | |
160 | .in -5 | |
161 | Access control (i.e. protection | |
162 | violation) | |
163 | except length violation SIGBUS | |
164 | Translation not valid, and | |
165 | Length access control SIGSEGV | |
166 | Reserved instruction SIGILL | |
167 | Customer-reserved instr. SIGEMT | |
168 | Reserved operand SIGILL | |
169 | Reserved addressing SIGILL | |
170 | Trace pending SIGTRAP | |
171 | Bpt instruction SIGTRAP | |
172 | Compatibility-mode SIGEMT | |
173 | Chme SIGSEGV | |
174 | Chms SIGSEGV | |
175 | Chmu SIGBUS | |
176 | .fi |