New variable 'project-files-relative-names'
[emacs.git] / lib / sigdescr_np.c
blobfb5401522f4c1f1ec065aa097359db8896a6968e
1 /* English descriptions of signals.
2 Copyright (C) 2020-2024 Free Software Foundation, Inc.
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 /* Written by Bruno Haible <bruno@clisp.org>, 2020. */
19 #include <config.h>
21 /* Specification. */
22 #include <string.h>
24 #include <signal.h>
26 const char *
27 sigdescr_np (int sig)
29 /* Note: Some platforms (glibc, FreeBSD, NetBSD, OpenBSD, AIX, IRIX, Haiku,
30 Android) have an array 'sys_siglist'. (On AIX, you need to declare it
31 yourself, and it has fewer than NSIG elements.) Its contents varies
32 depending on the OS.
33 On other OSes, you can invoke strsignal (sig) in the C locale.
34 In the code below, we show the differences.
35 You can see how cryptic some of these strings are. We try to pick more
36 understandable wordings. */
38 switch (sig)
40 /* Signals specified by ISO C. */
41 case SIGABRT:
42 /* glibc: "Aborted". *BSD: "Abort trap". Solaris: "Abort". */
43 return "Aborted";
44 case SIGFPE:
45 /* glibc, *BSD: "Floating point exception". Solaris: "Arithmetic exception".
46 The latter is more correct, because of integer division by 0 or -1. */
47 return "Arithmetic exception";
48 case SIGILL:
49 return "Illegal instruction";
50 case SIGINT:
51 return "Interrupt";
52 case SIGSEGV:
53 return "Segmentation fault";
54 case SIGTERM:
55 return "Terminated";
57 /* Signals specified by POSIX.
58 <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/signal.h.html> */
59 #if defined SIGALRM
60 case SIGALRM:
61 return "Alarm clock";
62 #endif
63 #if defined SIGBUS
64 case SIGBUS:
65 return "Bus error";
66 #endif
67 #if defined SIGCHLD
68 case SIGCHLD:
69 /* glibc, *BSD: "Child exited". Solaris: "Child status changed". */
70 return "Child stopped or exited";
71 #endif
72 #if defined SIGCONT
73 case SIGCONT:
74 return "Continued";
75 #endif
76 #if defined SIGHUP
77 case SIGHUP:
78 return "Hangup";
79 #endif
80 #if defined SIGKILL
81 case SIGKILL:
82 return "Killed";
83 #endif
84 #if defined SIGPIPE
85 case SIGPIPE:
86 return "Broken pipe";
87 #endif
88 #if defined SIGQUIT
89 case SIGQUIT:
90 return "Quit";
91 #endif
92 #if defined SIGSTOP
93 case SIGSTOP:
94 /* glibc, Solaris: "Stopped (signal)". *BSD: "Suspended (signal)". */
95 return "Stopped (signal)";
96 #endif
97 #if defined SIGTSTP
98 case SIGTSTP:
99 /* glibc: "Stopped". *BSD: "Suspended". Solaris: "Stopped (user)". */
100 return "Stopped";
101 #endif
102 #if defined SIGTTIN
103 case SIGTTIN:
104 return "Stopped (tty input)";
105 #endif
106 #if defined SIGTTOU
107 case SIGTTOU:
108 return "Stopped (tty output)";
109 #endif
110 #if defined SIGUSR1
111 case SIGUSR1:
112 /* glibc, *BSD: "User defined signal 1". Solaris: "User signal 1". */
113 return "User defined signal 1";
114 #endif
115 #if defined SIGUSR2
116 case SIGUSR2:
117 /* glibc, *BSD: "User defined signal 2". Solaris: "User signal 2". */
118 return "User defined signal 2";
119 #endif
120 #if defined SIGPOLL
121 case SIGPOLL:
122 /* glibc: "I/O possible". Solaris: "Pollable event". */
123 return "I/O possible";
124 #endif
125 #if defined SIGPROF
126 case SIGPROF:
127 return "Profiling timer expired";
128 #endif
129 #if defined SIGSYS
130 case SIGSYS:
131 return "Bad system call";
132 #endif
133 #if defined SIGTRAP
134 case SIGTRAP:
135 /* glibc, Solaris: "Trace/breakpoint trap". *BSD: "Trace/BPT trap". */
136 return "Trace/breakpoint trap";
137 #endif
138 #if defined SIGURG
139 case SIGURG:
140 /* glibc, *BSD: "Urgent I/O condition". Solaris: "Urgent socket condition". */
141 return "Urgent I/O condition";
142 #endif
143 #if defined SIGVTALRM
144 case SIGVTALRM:
145 return "Virtual timer expired";
146 #endif
147 #if defined SIGXCPU
148 case SIGXCPU:
149 /* glibc, *BSD: "CPU time limit exceeded". Solaris: "Cpu limit exceeded". */
150 return "CPU time limit exceeded";
151 #endif
152 #if defined SIGXFSZ
153 case SIGXFSZ:
154 return "File size limit exceeded";
155 #endif
157 /* Other signals on other systems. */
158 /* native Windows */
159 #if defined SIGBREAK
160 case SIGBREAK:
161 return "Ctrl-Break";
162 #endif
163 /* IRIX */
164 #if defined SIGCKPT
165 case SIGCKPT:
166 return "Checkpoint"; /* See man 1 cpr, man 3C atcheckpoint */
167 #endif
168 /* Linux, IRIX, Cygwin */
169 #if defined SIGCLD && SIGCLD != SIGCHLD
170 case SIGCLD:
171 return "Child stopped or exited";
172 #endif
173 /* AIX */
174 #if defined SIGCPUFAIL
175 case SIGCPUFAIL:
176 /* AIX: "CPU failure predicted". */
177 return "CPU going down"; /* See man bindprocessor */
178 #endif
179 /* AIX */
180 #if defined SIGDANGER
181 case SIGDANGER:
182 /* AIX: "Paging space low". */
183 return "Swap space nearly exhausted";
184 #endif
185 /* Mac OS X, FreeBSD, NetBSD, OpenBSD, Minix, AIX, IRIX, Cygwin, mingw */
186 #if defined SIGEMT
187 case SIGEMT:
188 /* glibc/Hurd, *BSD: "EMT trap". Solaris: "Emulation trap". */
189 return "Instruction emulation needed";
190 #endif
191 /* Mac OS X, FreeBSD, NetBSD, OpenBSD, Minix */
192 #if defined SIGINFO && SIGINFO != SIGPWR
193 case SIGINFO:
194 return "Information request";
195 #endif
196 /* Linux, Mac OS X, FreeBSD, NetBSD, OpenBSD, Minix, AIX, IRIX, Cygwin */
197 #if defined SIGIO && SIGIO != SIGPOLL
198 case SIGIO:
199 return "I/O possible";
200 #endif
201 /* Linux, IRIX, Cygwin, mingw */
202 #if defined SIGIOT && SIGIOT != SIGABRT
203 case SIGIOT:
204 return "IOT instruction"; /* a PDP-11 instruction */
205 #endif
206 /* AIX */
207 #if defined SIGKAP
208 case SIGKAP:
209 /* Process must issue a KSKAPACK ioctl, or will be killed in 30 seconds. */
210 /* AIX: "Monitor mode granted". */
211 return "Keep Alive Poll";
212 #endif
213 /* Haiku */
214 #if defined SIGKILLTHR
215 case SIGKILLTHR:
216 return "Kill thread";
217 #endif
218 /* Minix */
219 #if defined SIGKMEM
220 case SIGKMEM:
221 return "Kernel memory request";
222 #endif
223 /* Minix */
224 #if defined SIGKMESS
225 case SIGKMESS:
226 return "Kernel message";
227 #endif
228 /* Minix */
229 #if defined SIGKSIG
230 case SIGKSIG:
231 return "Kernel signal";
232 #endif
233 /* Minix */
234 #if defined SIGKSIGSM
235 case SIGKSIGSM:
236 return "Kernel signal for signal manager";
237 #endif
238 /* FreeBSD */
239 #if defined SIGLIBRT
240 case SIGLIBRT:
241 return "Real-time library interrupt";
242 #endif
243 /* Cygwin */
244 #if defined SIGLOST && SIGLOST != SIGABRT && SIGLOST != SIGPWR
245 case SIGLOST:
246 /* Solaris: "Resource lost". */
247 return "File lock lost";
248 #endif
249 /* AIX */
250 #if defined SIGMIGRATE
251 case SIGMIGRATE:
252 return "Process migration";
253 #endif
254 /* AIX */
255 #if defined SIGMSG
256 case SIGMSG:
257 /* AIX: "Input device data". */
258 return "Message in the ring";
259 #endif
260 /* ACM */
261 #if defined SIGPLAN
262 case SIGPLAN:
263 return "Programming language anomaly";
264 #endif
265 /* AIX */
266 #if defined SIGPRE
267 case SIGPRE:
268 return "Programmed exception";
269 #endif
270 /* IRIX */
271 #if defined SIGPTINTR
272 case SIGPTINTR:
273 return "Pthread interrupt";
274 #endif
275 /* IRIX */
276 #if defined SIGPTRESCHED
277 case SIGPTRESCHED:
278 return "Pthread rescheduling";
279 #endif
280 /* Linux, NetBSD, Minix, AIX, IRIX, Cygwin */
281 #if defined SIGPWR
282 case SIGPWR:
283 /* glibc: "Power failure". NetBSD: "Power fail/restart". */
284 return "Power failure";
285 #endif
286 /* AIX */
287 #if defined SIGRECONFIG
288 case SIGRECONFIG:
289 return "Dynamic logical partitioning changed";
290 #endif
291 /* AIX */
292 #if defined SIGRECOVERY
293 case SIGRECOVERY:
294 return "Kernel recovery";
295 #endif
296 /* IRIX */
297 #if defined SIGRESTART
298 case SIGRESTART:
299 return "Checkpoint restart"; /* See man 1 cpr, man 3C atrestart */
300 #endif
301 /* AIX */
302 #if defined SIGRETRACT
303 case SIGRETRACT:
304 /* AIX: "Monitor mode retracted". */
305 return "Retracting Keep Alive Poll";
306 #endif
307 /* AIX */
308 #if defined SIGSAK
309 case SIGSAK:
310 /* AIX: "Secure attention". */
311 return "Secure Attention Key";
312 #endif
313 /* ACM */
314 #if defined SIGSAM
315 case SIGSAM:
316 return "Symbolic computation failed";
317 #endif
318 /* Minix */
319 #if defined SIGSNDELAY
320 case SIGSNDELAY:
321 return "Done sending message";
322 #endif
323 /* AIX */
324 #if defined SIGSOUND
325 case SIGSOUND:
326 /* AIX: "Sound completed". */
327 return "Sound configuration changed";
328 #endif
329 /* Linux */
330 #if defined SIGSTKFLT
331 case SIGSTKFLT:
332 return "Stack fault";
333 #endif
334 /* AIX */
335 #if defined SIGSYSERROR
336 case SIGSYSERROR:
337 return "Kernel error";
338 #endif
339 /* AIX */
340 #if defined SIGTALRM
341 case SIGTALRM:
342 return "Thread alarm clock";
343 #endif
344 /* FreeBSD, OpenBSD */
345 #if defined SIGTHR
346 case SIGTHR:
347 /* OpenBSD: "Thread AST". */
348 return "Thread library interrupt";
349 #endif
350 /* IRIX */
351 #if defined SIGUME
352 case SIGUME:
353 return "Uncorrectable memory error";
354 #endif
355 /* AIX */
356 #if defined SIGVIRT
357 case SIGVIRT:
358 return "Virtual time alarm clock";
359 #endif
360 /* AIX */
361 #if defined SIGWAITING
362 case SIGWAITING:
363 /* AIX: "No runnable lwp". */
364 return "Thread waiting";
365 #endif
366 /* Linux, Mac OS X, FreeBSD, NetBSD, OpenBSD, Minix, AIX, IRIX, Cygwin, Haiku */
367 #if defined SIGWINCH
368 case SIGWINCH:
369 /* glibc: "Window changed". *BSD: "Window size changed" or "Window size changes". */
370 return "Window size changed";
371 #endif
373 default:
374 return NULL;