Commit | Line | Data |
---|---|---|
9d335a2c 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 | .\" | |
963ad392 | 5 | .\" @(#)signal.3 6.4 (Berkeley) %G% |
9d335a2c | 6 | .\" |
ec043d7a | 7 | .TH SIGNAL 3C "" |
9d335a2c | 8 | .UC 4 |
3c31698f KM |
9 | .ie t .ds d \(dg |
10 | .el .ds d \z'|+' | |
11 | .ie t .ds b \(bu | |
12 | .el .ds b @ | |
9d335a2c | 13 | .SH NAME |
3c31698f | 14 | signal \- simplified software signal facilities |
9d335a2c KM |
15 | .SH SYNOPSIS |
16 | .nf | |
17 | .B #include <signal.h> | |
18 | .PP | |
19 | .B (*signal(sig, func))() | |
c9d2bd73 | 20 | .B int (*func)(); |
9d335a2c KM |
21 | .fi |
22 | .SH DESCRIPTION | |
3c31698f KM |
23 | .I Signal |
24 | is a simplified interface to the more general | |
25 | .IR sigvec (2) | |
26 | facility. | |
9d335a2c KM |
27 | .PP |
28 | A signal | |
29 | is generated by some abnormal event, | |
3c31698f | 30 | initiated by a user at a terminal (quit, interrupt, stop), |
9d335a2c | 31 | by a program error (bus error, etc.), |
3c31698f KM |
32 | by request of another program (kill), |
33 | or when a process is stopped because it wishes to access | |
34 | its control terminal while in the background (see | |
35 | .IR tty (4)). | |
36 | Signals are optionally generated | |
37 | when a process resumes after being stopped, | |
38 | when the status of child processes changes, | |
39 | or when input is ready at the control terminal. | |
40 | Most signals cause termination of the receiving process if no action | |
41 | is taken; some signals instead cause the process receiving them | |
42 | to be stopped, or are simply discarded if the process has not | |
43 | requested otherwise. | |
44 | Except for the SIGKILL and SIGSTOP | |
45 | signals, the | |
9d335a2c | 46 | .I signal |
3c31698f | 47 | call allows signals either to be ignored |
9d335a2c | 48 | or to cause an interrupt to a specified location. |
3c31698f KM |
49 | The following is a list of all signals with |
50 | names as in the include file | |
51 | .RI < signal.h >: | |
9d335a2c KM |
52 | .LP |
53 | .nf | |
3c31698f | 54 | .ta \w'SIGVTALRM 'u +\w'15* 'u |
9d335a2c KM |
55 | SIGHUP 1 hangup |
56 | SIGINT 2 interrupt | |
57 | SIGQUIT 3* quit | |
3c31698f KM |
58 | SIGILL 4* illegal instruction |
59 | SIGTRAP 5* trace trap | |
9d335a2c KM |
60 | SIGIOT 6* IOT instruction |
61 | SIGEMT 7* EMT instruction | |
62 | SIGFPE 8* floating point exception | |
63 | SIGKILL 9 kill (cannot be caught or ignored) | |
64 | SIGBUS 10* bus error | |
65 | SIGSEGV 11* segmentation violation | |
66 | SIGSYS 12* bad argument to system call | |
67 | SIGPIPE 13 write on a pipe with no one to read it | |
68 | SIGALRM 14 alarm clock | |
69 | SIGTERM 15 software termination signal | |
3c31698f KM |
70 | SIGURG 16\*b urgent condition present on socket |
71 | SIGSTOP 17\*d stop (cannot be caught or ignored) | |
72 | SIGTSTP 18\*d stop signal generated from keyboard | |
73 | SIGCONT 19\*b continue after stop | |
74 | SIGCHLD 20\*b child status has changed | |
75 | SIGTTIN 21\*d background read attempted from control terminal | |
76 | SIGTTOU 22\*d background write attempted to control terminal | |
77 | SIGIO 23\*b i/o is possible on a descriptor (see \fIfcntl\fP(2)) | |
78 | SIGXCPU 24 cpu time limit exceeded (see \fIsetrlimit\fP(2)) | |
79 | SIGXFSZ 25 file size limit exceeded (see \fIsetrlimit\fP(2)) | |
80 | SIGVTALRM 26 virtual time alarm (see \fIsetitimer\fP(2)) | |
81 | SIGPROF 27 profiling timer alarm (see \fIsetitimer\fP(2)) | |
c9d2bd73 | 82 | SIGWINCH 28\*b Window size change |
c44b06d2 KM |
83 | SIGUSR1 30 User defined signal 1 |
84 | SIGUSR2 31 User defined signal 2 | |
9d335a2c | 85 | .fi |
9d335a2c KM |
86 | .PP |
87 | The starred signals in the list above cause a core image | |
88 | if not caught or ignored. | |
89 | .PP | |
90 | If | |
91 | .I func | |
92 | is SIG_DFL, the default action | |
93 | for signal | |
94 | .I sig | |
3c31698f KM |
95 | is reinstated; this default is termination |
96 | (with a core image for starred signals) | |
97 | except for signals marked with \*b or \*d. | |
98 | Signals marked with \*b are discarded if the action | |
99 | is SIG_DFL; signals marked | |
100 | with \*d cause the process to stop. | |
9d335a2c KM |
101 | If |
102 | .I func | |
3c31698f KM |
103 | is SIG_IGN the signal is subsequently ignored |
104 | and pending instances of the signal are discarded. | |
105 | Otherwise, when the signal occurs | |
963ad392 | 106 | further occurrences of the signal are |
3c31698f | 107 | automatically blocked and |
9d335a2c | 108 | .I func |
3c31698f | 109 | is called. |
9d335a2c | 110 | .PP |
3c31698f KM |
111 | A return from the function unblocks |
112 | the handled signal and | |
113 | continues the process at the point it was interrupted. | |
114 | \fBUnlike previous signal facilities, the handler \fIfunc\fP | |
115 | remains installed after a signal has been delivered.\fP | |
9d335a2c | 116 | .PP |
3c31698f KM |
117 | If a caught signal occurs |
118 | during certain system calls, causing | |
119 | the call to terminate prematurely, the call | |
120 | is automatically restarted. | |
9d335a2c | 121 | In particular this can occur |
3c31698f KM |
122 | during a |
123 | .I read | |
9d335a2c KM |
124 | or |
125 | .IR write (2) | |
3c31698f KM |
126 | on a slow device (such as a terminal; but not a file) |
127 | and during a | |
9d335a2c | 128 | .IR wait (2). |
9d335a2c KM |
129 | .PP |
130 | The value of | |
131 | .I signal | |
132 | is the previous (or initial) | |
133 | value of | |
134 | .I func | |
135 | for the particular signal. | |
136 | .PP | |
137 | After a | |
3c31698f KM |
138 | .IR fork (2) |
139 | or | |
140 | .IR vfork (2) | |
9d335a2c KM |
141 | the child inherits |
142 | all signals. | |
3c31698f KM |
143 | .IR Execve (2) |
144 | resets all caught signals to the default action; | |
145 | ignored signals remain ignored. | |
146 | .SH "RETURN VALUE | |
147 | The previous action is returned on a successful call. | |
148 | Otherwise, \-1 is returned and | |
149 | .I errno | |
150 | is set to indicate the error. | |
151 | .SH ERRORS | |
152 | .I Signal | |
153 | will fail and no action will take place if one of the | |
154 | following occur: | |
155 | .TP 15 | |
156 | [EINVAL] | |
157 | .I Sig | |
158 | is not a valid signal number. | |
159 | .TP 15 | |
160 | [EINVAL] | |
161 | An attempt is made to ignore or supply a handler for SIGKILL | |
162 | or SIGSTOP. | |
163 | .TP 15 | |
164 | [EINVAL] | |
165 | An attempt is made to ignore SIGCONT (by default SIGCONT | |
166 | is ignored). | |
9d335a2c | 167 | .SH "SEE ALSO" |
9d335a2c | 168 | kill(1), |
3c31698f KM |
169 | ptrace(2), kill(2), |
170 | sigvec(2), sigblock(2), sigsetmask(2), sigpause(2), | |
171 | sigstack(2), setjmp(3), tty(4) | |
172 | .SH "NOTES (VAX-11)" | |
173 | The handler routine can be declared: | |
9d335a2c | 174 | .PP |
3c31698f | 175 | handler(sig, code, scp) |
9d335a2c | 176 | .PP |
3c31698f KM |
177 | Here |
178 | .I sig | |
179 | is the signal number, into which the hardware faults and traps are | |
180 | mapped as defined below. Code is a parameter which is either a constant | |
181 | as given below or, for compatibility mode faults, the code provided by | |
182 | the hardware. | |
183 | .I Scp | |
184 | is a pointer to the | |
185 | .I "struct sigcontext" | |
186 | used by the system to restore the process context from before | |
187 | the signal. | |
188 | Compatibility mode faults are distinguished from the | |
189 | other SIGILL traps by having PSL_CM set in the psl. | |
9d335a2c | 190 | .PP |
3c31698f KM |
191 | The following defines the mapping of hardware traps to signals |
192 | and codes. All of these symbols are defined in | |
193 | .RI < signal.h >: | |
194 | .LP | |
195 | .ta \w' Floating/decimal divide by zero 'u +\w'15* 'u +8n | |
196 | .nf | |
197 | Hardware condition Signal Code | |
198 | ||
199 | Arithmetic traps: | |
200 | Integer overflow SIGFPE FPE_INTOVF_TRAP | |
201 | Integer division by zero SIGFPE FPE_INTDIV_TRAP | |
202 | Floating overflow trap SIGFPE FPE_FLTOVF_TRAP | |
203 | Floating/decimal division by zero SIGFPE FPE_FLTDIV_TRAP | |
204 | Floating underflow trap SIGFPE FPE_FLTUND_TRAP | |
205 | Decimal overflow trap SIGFPE FPE_DECOVF_TRAP | |
206 | Subscript-range SIGFPE FPE_SUBRNG_TRAP | |
207 | Floating overflow fault SIGFPE FPE_FLTOVF_FAULT | |
208 | Floating divide by zero fault SIGFPE FPE_FLTDIV_FAULT | |
209 | Floating underflow fault SIGFPE FPE_FLTUND_FAULT | |
210 | Length access control SIGSEGV | |
211 | Protection violation SIGBUS | |
212 | Reserved instruction SIGILL ILL_RESAD_FAULT | |
213 | Customer-reserved instr. SIGEMT | |
214 | Reserved operand SIGILL ILL_PRIVIN_FAULT | |
215 | Reserved addressing SIGILL ILL_RESOP_FAULT | |
216 | Trace pending SIGTRAP | |
217 | Bpt instruction SIGTRAP | |
218 | Compatibility-mode SIGILL hardware supplied code | |
219 | Chme SIGSEGV | |
220 | Chms SIGSEGV | |
221 | Chmu SIGSEGV | |
222 | .fi |