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