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 | .\" | |
bc9788fb | 5 | .\" @(#)signal.3 6.5 (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 | |
bc9788fb MK |
19 | .B void (*signal(sig, func))() |
20 | .B void (*func)(); | |
9d335a2c KM |
21 | .fi |
22 | .SH DESCRIPTION | |
3c31698f KM |
23 | .I Signal |
24 | is a simplified interface to the more general | |
bc9788fb | 25 | .IR sigaction (2) |
3c31698f | 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 | |
bc9788fb | 60 | SIGABRT 6* \fIabort\fP() call (formerly SIGIOT) |
9d335a2c KM |
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 |
bc9788fb | 83 | SIGINFO 29\*b status request from keyboard |
c44b06d2 KM |
84 | SIGUSR1 30 User defined signal 1 |
85 | SIGUSR2 31 User defined signal 2 | |
9d335a2c | 86 | .fi |
9d335a2c KM |
87 | .PP |
88 | The starred signals in the list above cause a core image | |
89 | if not caught or ignored. | |
90 | .PP | |
91 | If | |
92 | .I func | |
93 | is SIG_DFL, the default action | |
94 | for signal | |
95 | .I sig | |
3c31698f KM |
96 | is reinstated; this default is termination |
97 | (with a core image for starred signals) | |
98 | except for signals marked with \*b or \*d. | |
99 | Signals marked with \*b are discarded if the action | |
100 | is SIG_DFL; signals marked | |
101 | with \*d cause the process to stop. | |
9d335a2c KM |
102 | If |
103 | .I func | |
3c31698f KM |
104 | is SIG_IGN the signal is subsequently ignored |
105 | and pending instances of the signal are discarded. | |
106 | Otherwise, when the signal occurs | |
963ad392 | 107 | further occurrences of the signal are |
3c31698f | 108 | automatically blocked and |
9d335a2c | 109 | .I func |
3c31698f | 110 | is called. |
9d335a2c | 111 | .PP |
3c31698f KM |
112 | A return from the function unblocks |
113 | the handled signal and | |
114 | continues the process at the point it was interrupted. | |
115 | \fBUnlike previous signal facilities, the handler \fIfunc\fP | |
116 | remains installed after a signal has been delivered.\fP | |
9d335a2c | 117 | .PP |
3c31698f KM |
118 | If a caught signal occurs |
119 | during certain system calls, causing | |
120 | the call to terminate prematurely, the call | |
bc9788fb MK |
121 | is automatically restarted |
122 | (the handler is installed using the SA_RESTART flag with | |
123 | .IR sigaction (2)). | |
124 | The affected system calls include | |
125 | .IR read (2), | |
126 | .IR write (2), | |
127 | .IR sendto (2), | |
128 | .IR recvfrom (2), | |
129 | .IR sendmsg (2) | |
130 | and | |
131 | .IR recvmsg (2) | |
132 | on a communications channel or a slow device (such as a terminal, | |
133 | but not a regular file) | |
3c31698f | 134 | and during a |
bc9788fb MK |
135 | .IR wait (2) |
136 | or | |
137 | .IR ioctl (2). | |
138 | However, calls that have already committed are not restarted, | |
139 | but instead return a partial success (for example, a short read count). | |
9d335a2c KM |
140 | .PP |
141 | The value of | |
142 | .I signal | |
143 | is the previous (or initial) | |
144 | value of | |
145 | .I func | |
146 | for the particular signal. | |
147 | .PP | |
148 | After a | |
3c31698f KM |
149 | .IR fork (2) |
150 | or | |
151 | .IR vfork (2) | |
9d335a2c KM |
152 | the child inherits |
153 | all signals. | |
3c31698f KM |
154 | .IR Execve (2) |
155 | resets all caught signals to the default action; | |
156 | ignored signals remain ignored. | |
157 | .SH "RETURN VALUE | |
158 | The previous action is returned on a successful call. | |
159 | Otherwise, \-1 is returned and | |
160 | .I errno | |
161 | is set to indicate the error. | |
162 | .SH ERRORS | |
163 | .I Signal | |
164 | will fail and no action will take place if one of the | |
165 | following occur: | |
166 | .TP 15 | |
167 | [EINVAL] | |
168 | .I Sig | |
169 | is not a valid signal number. | |
170 | .TP 15 | |
171 | [EINVAL] | |
172 | An attempt is made to ignore or supply a handler for SIGKILL | |
173 | or SIGSTOP. | |
9d335a2c | 174 | .SH "SEE ALSO" |
bc9788fb MK |
175 | kill(1), ptrace(2), kill(2), |
176 | sigaction(2), sigprocmask(2), sigsuspend(2), | |
3c31698f KM |
177 | sigstack(2), setjmp(3), tty(4) |
178 | .SH "NOTES (VAX-11)" | |
179 | The handler routine can be declared: | |
9d335a2c | 180 | .PP |
bc9788fb | 181 | void handler(sig, code, scp) |
9d335a2c | 182 | .PP |
3c31698f KM |
183 | Here |
184 | .I sig | |
185 | is the signal number, into which the hardware faults and traps are | |
186 | mapped as defined below. Code is a parameter which is either a constant | |
187 | as given below or, for compatibility mode faults, the code provided by | |
188 | the hardware. | |
189 | .I Scp | |
190 | is a pointer to the | |
191 | .I "struct sigcontext" | |
192 | used by the system to restore the process context from before | |
193 | the signal. | |
194 | Compatibility mode faults are distinguished from the | |
195 | other SIGILL traps by having PSL_CM set in the psl. | |
9d335a2c | 196 | .PP |
3c31698f KM |
197 | The following defines the mapping of hardware traps to signals |
198 | and codes. All of these symbols are defined in | |
199 | .RI < signal.h >: | |
200 | .LP | |
201 | .ta \w' Floating/decimal divide by zero 'u +\w'15* 'u +8n | |
202 | .nf | |
203 | Hardware condition Signal Code | |
204 | ||
205 | Arithmetic traps: | |
206 | Integer overflow SIGFPE FPE_INTOVF_TRAP | |
207 | Integer division by zero SIGFPE FPE_INTDIV_TRAP | |
208 | Floating overflow trap SIGFPE FPE_FLTOVF_TRAP | |
209 | Floating/decimal division by zero SIGFPE FPE_FLTDIV_TRAP | |
210 | Floating underflow trap SIGFPE FPE_FLTUND_TRAP | |
211 | Decimal overflow trap SIGFPE FPE_DECOVF_TRAP | |
212 | Subscript-range SIGFPE FPE_SUBRNG_TRAP | |
213 | Floating overflow fault SIGFPE FPE_FLTOVF_FAULT | |
214 | Floating divide by zero fault SIGFPE FPE_FLTDIV_FAULT | |
215 | Floating underflow fault SIGFPE FPE_FLTUND_FAULT | |
216 | Length access control SIGSEGV | |
217 | Protection violation SIGBUS | |
218 | Reserved instruction SIGILL ILL_RESAD_FAULT | |
219 | Customer-reserved instr. SIGEMT | |
220 | Reserved operand SIGILL ILL_PRIVIN_FAULT | |
221 | Reserved addressing SIGILL ILL_RESOP_FAULT | |
222 | Trace pending SIGTRAP | |
223 | Bpt instruction SIGTRAP | |
224 | Compatibility-mode SIGILL hardware supplied code | |
225 | Chme SIGSEGV | |
226 | Chms SIGSEGV | |
227 | Chmu SIGSEGV | |
228 | .fi |