1 /* signames.c -- Create an array of signal names. */
3 /* Copyright (C) 2006-2020 Free Software Foundation, Inc.
5 This file is part of GNU Bush, the Bourne Again SHell.
7 Bush is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 Bush is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Bush. If not, see <http://www.gnu.org/licenses/>.
25 #include <sys/types.h>
28 #if defined (HAVE_STDLIB_H)
31 # include "ansi_stdlib.h"
32 #endif /* HAVE_STDLIB_H */
45 #define LASTSIG NSIG+2
47 char *signal_names
[2 * (LASTSIG
)];
49 #define signal_names_size (sizeof(signal_names)/sizeof(signal_names[0]))
51 /* AIX 4.3 defines SIGRTMIN and SIGRTMAX as 888 and 999 respectively.
52 I don't want to allocate so much unused space for the intervening signal
53 numbers, so we just punt if SIGRTMAX is past the bounds of the
54 signal_names array (handled in configure). */
55 #if defined (SIGRTMAX) && defined (UNUSABLE_RT_SIGNALS)
60 #if defined (SIGRTMAX) || defined (SIGRTMIN)
65 #if defined (BUILDTOOL)
66 extern char *progname
;
70 initialize_signames ()
73 #if defined (SIGRTMAX) || defined (SIGRTMIN)
74 int rtmin
, rtmax
, rtcnt
;
77 for (i
= 1; i
< signal_names_size
; i
++)
78 signal_names
[i
] = (char *)NULL
;
80 /* `signal' 0 is what we do on exit. */
81 signal_names
[0] = "EXIT";
83 /* Place signal names which can be aliases for more common signal
84 names first. This allows (for example) SIGABRT to overwrite SIGLOST. */
86 /* POSIX 1003.1b-1993 real time signals, but take care of incomplete
87 implementations. Acoording to the standard, both, SIGRTMIN and
88 SIGRTMAX must be defined, SIGRTMIN must be strictly less than
89 SIGRTMAX, and the difference must be at least 7, that is, there
90 must be at least eight distinct real time signals. */
92 /* The generated signal names are SIGRTMIN, SIGRTMIN+1, ...,
93 SIGRTMIN+x, SIGRTMAX-x, ..., SIGRTMAX-1, SIGRTMAX. If the number
94 of RT signals is odd, there is an extra SIGRTMIN+(x+1).
95 These names are the ones used by ksh and /usr/xpg4/bin/sh on SunOS5. */
97 #if defined (SIGRTMIN)
99 signal_names
[rtmin
] = "SIGRTMIN";
102 #if defined (SIGRTMAX)
104 signal_names
[rtmax
] = "SIGRTMAX";
107 #if defined (SIGRTMAX) && defined (SIGRTMIN)
110 rtcnt
= (rtmax
- rtmin
- 1) / 2;
111 /* croak if there are too many RT signals */
112 if (rtcnt
>= RTLIM
/2)
116 fprintf(stderr
, "%s: error: more than %d real time signals, fix `%s'\n",
117 progname
, RTLIM
, progname
);
121 for (i
= 1; i
<= rtcnt
; i
++)
123 signal_names
[rtmin
+i
] = (char *)malloc(RTLEN
);
124 if (signal_names
[rtmin
+i
])
125 sprintf (signal_names
[rtmin
+i
], "SIGRTMIN+%d", i
);
126 signal_names
[rtmax
-i
] = (char *)malloc(RTLEN
);
127 if (signal_names
[rtmax
-i
])
128 sprintf (signal_names
[rtmax
-i
], "SIGRTMAX-%d", i
);
131 if (rtcnt
< RTLIM
/2-1 && rtcnt
!= (rtmax
-rtmin
)/2)
133 /* Need an extra RTMIN signal */
134 signal_names
[rtmin
+rtcnt
+1] = (char *)malloc(RTLEN
);
135 if (signal_names
[rtmin
+rtcnt
+1])
136 sprintf (signal_names
[rtmin
+rtcnt
+1], "SIGRTMIN+%d", rtcnt
+1);
139 #endif /* SIGRTMIN && SIGRTMAX */
141 #if defined (SIGLOST) /* resource lost (eg, record-lock lost) */
142 signal_names
[SIGLOST
] = "SIGLOST";
146 #if defined (SIGMSG) /* HFT input data pending */
147 signal_names
[SIGMSG
] = "SIGMSG";
150 #if defined (SIGDANGER) /* system crash imminent */
151 signal_names
[SIGDANGER
] = "SIGDANGER";
154 #if defined (SIGMIGRATE) /* migrate process to another CPU */
155 signal_names
[SIGMIGRATE
] = "SIGMIGRATE";
158 #if defined (SIGPRE) /* programming error */
159 signal_names
[SIGPRE
] = "SIGPRE";
162 #if defined (SIGPHONE) /* Phone interrupt */
163 signal_names
[SIGPHONE
] = "SIGPHONE";
166 #if defined (SIGVIRT) /* AIX virtual time alarm */
167 signal_names
[SIGVIRT
] = "SIGVIRT";
170 #if defined (SIGTINT) /* Interrupt */
171 signal_names
[SIGTINT
] = "SIGTINT";
174 #if defined (SIGALRM1) /* m:n condition variables */
175 signal_names
[SIGALRM1
] = "SIGALRM1";
178 #if defined (SIGWAITING) /* m:n scheduling */
179 signal_names
[SIGWAITING
] = "SIGWAITING";
182 #if defined (SIGGRANT) /* HFT monitor mode granted */
183 signal_names
[SIGGRANT
] = "SIGGRANT";
186 #if defined (SIGKAP) /* keep alive poll from native keyboard */
187 signal_names
[SIGKAP
] = "SIGKAP";
190 #if defined (SIGRETRACT) /* HFT monitor mode retracted */
191 signal_names
[SIGRETRACT
] = "SIGRETRACT";
194 #if defined (SIGSOUND) /* HFT sound sequence has completed */
195 signal_names
[SIGSOUND
] = "SIGSOUND";
198 #if defined (SIGSAK) /* Secure Attention Key */
199 signal_names
[SIGSAK
] = "SIGSAK";
202 #if defined (SIGCPUFAIL) /* Predictive processor deconfiguration */
203 signal_names
[SIGCPUFAIL
] = "SIGCPUFAIL";
206 #if defined (SIGAIO) /* Asynchronous I/O */
207 signal_names
[SIGAIO
] = "SIGAIO";
210 #if defined (SIGLAB) /* Security label changed */
211 signal_names
[SIGLAB
] = "SIGLAB";
215 #if defined (SIGLWP) /* Solaris: special signal used by thread library */
216 signal_names
[SIGLWP
] = "SIGLWP";
219 #if defined (SIGFREEZE) /* Solaris: special signal used by CPR */
220 signal_names
[SIGFREEZE
] = "SIGFREEZE";
223 #if defined (SIGTHAW) /* Solaris: special signal used by CPR */
224 signal_names
[SIGTHAW
] = "SIGTHAW";
227 #if defined (SIGCANCEL) /* Solaris: thread cancellation signal used by libthread */
228 signal_names
[SIGCANCEL
] = "SIGCANCEL";
231 #if defined (SIGXRES) /* Solaris: resource control exceeded */
232 signal_names
[SIGXRES
] = "SIGXRES";
235 #if defined (SIGJVM1) /* Solaris: Java Virtual Machine 1 */
236 signal_names
[SIGJVM1
] = "SIGJVM1";
239 #if defined (SIGJVM2) /* Solaris: Java Virtual Machine 2 */
240 signal_names
[SIGJVM2
] = "SIGJVM2";
243 #if defined (SIGDGTIMER1)
244 signal_names
[SIGDGTIMER1
] = "SIGDGTIMER1";
247 #if defined (SIGDGTIMER2)
248 signal_names
[SIGDGTIMER2
] = "SIGDGTIMER2";
251 #if defined (SIGDGTIMER3)
252 signal_names
[SIGDGTIMER3
] = "SIGDGTIMER3";
255 #if defined (SIGDGTIMER4)
256 signal_names
[SIGDGTIMER4
] = "SIGDGTIMER4";
259 #if defined (SIGDGNOTIFY)
260 signal_names
[SIGDGNOTIFY
] = "SIGDGNOTIFY";
264 #if defined (SIGAPOLLO)
265 signal_names
[SIGAPOLLO
] = "SIGAPOLLO";
269 #if defined (SIGDIL) /* DIL signal (?) */
270 signal_names
[SIGDIL
] = "SIGDIL";
274 #if defined (SIGCLD) /* Like SIGCHLD. */
275 signal_names
[SIGCLD
] = "SIGCLD";
278 #if defined (SIGPWR) /* power state indication */
279 signal_names
[SIGPWR
] = "SIGPWR";
282 #if defined (SIGPOLL) /* Pollable event (for streams) */
283 signal_names
[SIGPOLL
] = "SIGPOLL";
287 #if defined (SIGWINDOW)
288 signal_names
[SIGWINDOW
] = "SIGWINDOW";
292 #if defined (SIGSTKFLT)
293 signal_names
[SIGSTKFLT
] = "SIGSTKFLT";
297 #if defined (SIGTHR) /* thread interrupt */
298 signal_names
[SIGTHR
] = "SIGTHR";
302 #if defined (SIGHUP) /* hangup */
303 signal_names
[SIGHUP
] = "SIGHUP";
306 #if defined (SIGINT) /* interrupt */
307 signal_names
[SIGINT
] = "SIGINT";
310 #if defined (SIGQUIT) /* quit */
311 signal_names
[SIGQUIT
] = "SIGQUIT";
314 #if defined (SIGILL) /* illegal instruction (not reset when caught) */
315 signal_names
[SIGILL
] = "SIGILL";
318 #if defined (SIGTRAP) /* trace trap (not reset when caught) */
319 signal_names
[SIGTRAP
] = "SIGTRAP";
322 #if defined (SIGIOT) /* IOT instruction */
323 signal_names
[SIGIOT
] = "SIGIOT";
326 #if defined (SIGABRT) /* Cause current process to dump core. */
327 signal_names
[SIGABRT
] = "SIGABRT";
330 #if defined (SIGEMT) /* EMT instruction */
331 signal_names
[SIGEMT
] = "SIGEMT";
334 #if defined (SIGFPE) /* floating point exception */
335 signal_names
[SIGFPE
] = "SIGFPE";
338 #if defined (SIGKILL) /* kill (cannot be caught or ignored) */
339 signal_names
[SIGKILL
] = "SIGKILL";
342 #if defined (SIGBUS) /* bus error */
343 signal_names
[SIGBUS
] = "SIGBUS";
346 #if defined (SIGSEGV) /* segmentation violation */
347 signal_names
[SIGSEGV
] = "SIGSEGV";
350 #if defined (SIGSYS) /* bad argument to system call */
351 signal_names
[SIGSYS
] = "SIGSYS";
354 #if defined (SIGPIPE) /* write on a pipe with no one to read it */
355 signal_names
[SIGPIPE
] = "SIGPIPE";
358 #if defined (SIGALRM) /* alarm clock */
359 signal_names
[SIGALRM
] = "SIGALRM";
362 #if defined (SIGTERM) /* software termination signal from kill */
363 signal_names
[SIGTERM
] = "SIGTERM";
366 #if defined (SIGURG) /* urgent condition on IO channel */
367 signal_names
[SIGURG
] = "SIGURG";
370 #if defined (SIGSTOP) /* sendable stop signal not from tty */
371 signal_names
[SIGSTOP
] = "SIGSTOP";
374 #if defined (SIGTSTP) /* stop signal from tty */
375 signal_names
[SIGTSTP
] = "SIGTSTP";
378 #if defined (SIGCONT) /* continue a stopped process */
379 signal_names
[SIGCONT
] = "SIGCONT";
382 #if defined (SIGCHLD) /* to parent on child stop or exit */
383 signal_names
[SIGCHLD
] = "SIGCHLD";
386 #if defined (SIGTTIN) /* to readers pgrp upon background tty read */
387 signal_names
[SIGTTIN
] = "SIGTTIN";
390 #if defined (SIGTTOU) /* like TTIN for output if (tp->t_local<OSTOP) */
391 signal_names
[SIGTTOU
] = "SIGTTOU";
394 #if defined (SIGIO) /* input/output possible signal */
395 signal_names
[SIGIO
] = "SIGIO";
398 #if defined (SIGXCPU) /* exceeded CPU time limit */
399 signal_names
[SIGXCPU
] = "SIGXCPU";
402 #if defined (SIGXFSZ) /* exceeded file size limit */
403 signal_names
[SIGXFSZ
] = "SIGXFSZ";
406 #if defined (SIGVTALRM) /* virtual time alarm */
407 signal_names
[SIGVTALRM
] = "SIGVTALRM";
410 #if defined (SIGPROF) /* profiling time alarm */
411 signal_names
[SIGPROF
] = "SIGPROF";
414 #if defined (SIGWINCH) /* window changed */
415 signal_names
[SIGWINCH
] = "SIGWINCH";
419 #if defined (SIGINFO) && !defined (_SEQUENT_) /* information request */
420 signal_names
[SIGINFO
] = "SIGINFO";
423 #if defined (SIGUSR1) /* user defined signal 1 */
424 signal_names
[SIGUSR1
] = "SIGUSR1";
427 #if defined (SIGUSR2) /* user defined signal 2 */
428 signal_names
[SIGUSR2
] = "SIGUSR2";
431 #if defined (SIGKILLTHR) /* BeOS: Kill Thread */
432 signal_names
[SIGKILLTHR
] = "SIGKILLTHR";
435 for (i
= 0; i
< NSIG
; i
++)
436 if (signal_names
[i
] == (char *)NULL
)
438 signal_names
[i
] = (char *)malloc (18);
440 sprintf (signal_names
[i
], "SIGJUNK(%d)", i
);
443 signal_names
[NSIG
] = "DEBUG";
444 signal_names
[NSIG
+1] = "ERR";
445 signal_names
[NSIG
+2] = "RETURN";