]>
git.ipfire.org Git - thirdparty/bash.git/blob - support/mksignames.c
1 /* signames.c -- Create and write `signames.h', which contains an array of
4 /* Copyright (C) 1992 Free Software Foundation, Inc.
6 This file is part of GNU Bash, the Bourne Again SHell.
8 Bash is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 2, or (at your option) any later
13 Bash is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License along
19 with Bash; see the file COPYING. If not, write to the Free Software
20 Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
23 #include <sys/types.h>
25 #if defined (HAVE_STDLIB_H)
28 # include "ansi_stdlib.h"
29 #endif /* HAVE_STDLIB_H */
35 char *signal_names
[2 * NSIG
];
39 #if defined (SIGRTMAX) || defined (SIGRTMIN)
45 initialize_signames ()
48 #if defined (SIGRTMAX) || defined (SIGRTMIN)
49 int rtmin
, rtmax
, rtcnt
;
52 for (i
= 1; i
< sizeof(signal_names
)/sizeof(signal_names
[0]); i
++)
53 signal_names
[i
] = (char *)NULL
;
55 /* `signal' 0 is what we do on exit. */
56 signal_names
[0] = "EXIT";
58 /* Place signal names which can be aliases for more common signal
59 names first. This allows (for example) SIGABRT to overwrite SIGLOST. */
61 /* POSIX 1003.1b-1993 real time signals, but take care of incomplete
62 implementations. Acoording to the standard, both, SIGRTMIN and
63 SIGRTMAX must be defined, SIGRTMIN must be stricly less than
64 SIGRTMAX, and the difference must be at least 7, that is, there
65 must be at least eight distinct real time signals. */
67 /* The generated signal names are SIGRTMIN, SIGRTMIN+1, ...,
68 SIGRTMIN+x, SIGRTMAX-x, ..., SIGRTMAX-1, SIGRTMAX. If the number
69 of RT signals is odd, there is an extra SIGRTMIN+(x+1).
70 These names are the ones used by ksh and /usr/xpg4/bin/sh on SunOS5. */
72 #if defined (SIGRTMIN)
74 signal_names
[rtmin
] = "SIGRTMIN";
77 #if defined (SIGRTMAX)
79 signal_names
[rtmax
] = "SIGRTMAX";
82 #if defined (SIGRTMAX) && defined (SIGRTMIN)
85 rtcnt
= (rtmax
- rtmin
- 1) / 2;
86 /* croak if there are too many RT signals */
90 fprintf(stderr
, "%s: error: more than %i real time signals, fix `%s'\n",
91 progname
, RTLIM
, progname
);
94 for (i
= 1; i
<= rtcnt
; i
++)
96 signal_names
[rtmin
+i
] = (char *)malloc(RTLEN
);
97 sprintf (signal_names
[rtmin
+i
], "SIGRTMIN+%d", i
);
98 signal_names
[rtmax
-i
] = (char *)malloc(RTLEN
);
99 sprintf (signal_names
[rtmax
-i
], "SIGRTMAX-%d", i
);
102 if (rtcnt
< RTLIM
/2-1 && rtcnt
!= (rtmax
-rtmin
)/2)
104 /* Need an extra RTMIN signal */
105 signal_names
[rtmin
+rtcnt
+1] = (char *)malloc(RTLEN
);
106 sprintf (signal_names
[rtmin
+rtcnt
+1], "SIGRTMIN+%d", rtcnt
+1);
109 #endif /* SIGRTMIN && SIGRTMAX */
112 #if defined (SIGLOST) /* resource lost (eg, record-lock lost) */
113 signal_names
[SIGLOST
] = "SIGLOST";
116 #if defined (SIGMSG) /* HFT input data pending */
117 signal_names
[SIGMSG
] = "SIGMSG";
120 #if defined (SIGDANGER) /* system crash imminent */
121 signal_names
[SIGDANGER
] = "SIGDANGER";
124 #if defined (SIGMIGRATE) /* migrate process to another CPU */
125 signal_names
[SIGMIGRATE
] = "SIGMIGRATE";
128 #if defined (SIGPRE) /* programming error */
129 signal_names
[SIGPRE
] = "SIGPRE";
132 #if defined (SIGVIRT) /* AIX virtual time alarm */
133 signal_names
[SIGVIRT
] = "SIGVIRT";
136 #if defined (SIGALRM1) /* m:n condition variables */
137 signal_names
[SIGALRM1
] = "SIGALRM1";
140 #if defined (SIGWAITING) /* m:n scheduling */
141 signal_names
[SIGWAITING
] = "SIGWAITING";
144 #if defined (SIGGRANT) /* HFT monitor mode granted */
145 signal_names
[SIGGRANT
] = "SIGGRANT";
148 #if defined (SIGKAP) /* keep alive poll from native keyboard */
149 signal_names
[SIGKAP
] = "SIGKAP";
152 #if defined (SIGRETRACT) /* HFT monitor mode retracted */
153 signal_names
[SIGRETRACT
] = "SIGRETRACT";
156 #if defined (SIGSOUND) /* HFT sound sequence has completed */
157 signal_names
[SIGSOUND
] = "SIGSOUND";
160 #if defined (SIGSAK) /* Secure Attention Key */
161 signal_names
[SIGSAK
] = "SIGSAK";
165 #if defined (SIGLWP) /* special signal used by thread library */
166 signal_names
[SIGLWP
] = "SIGLWP";
169 #if defined (SIGFREEZE) /* special signal used by CPR */
170 signal_names
[SIGFREEZE
] = "SIGFREEZE";
173 #if defined (SIGTHAW) /* special signal used by CPR */
174 signal_names
[SIGTHAW
] = "SIGTHAW";
177 #if defined (SIGCANCEL) /* thread cancellation signal used by libthread */
178 signal_names
[SIGCANCEL
] = "SIGCANCEL";
182 #if defined (SIGDIL) /* DIL signal (?) */
183 signal_names
[SIGDIL
] = "SIGDIL";
187 #if defined (SIGCLD) /* Like SIGCHLD. */
188 signal_names
[SIGCLD
] = "SIGCLD";
191 #if defined (SIGPWR) /* power state indication */
192 signal_names
[SIGPWR
] = "SIGPWR";
195 #if defined (SIGPOLL) /* Pollable event (for streams) */
196 signal_names
[SIGPOLL
] = "SIGPOLL";
200 #if defined (SIGWINDOW)
201 signal_names
[SIGWINDOW
] = "SIGWINDOW";
205 #if defined (SIGHUP) /* hangup */
206 signal_names
[SIGHUP
] = "SIGHUP";
209 #if defined (SIGINT) /* interrupt */
210 signal_names
[SIGINT
] = "SIGINT";
213 #if defined (SIGQUIT) /* quit */
214 signal_names
[SIGQUIT
] = "SIGQUIT";
217 #if defined (SIGILL) /* illegal instruction (not reset when caught) */
218 signal_names
[SIGILL
] = "SIGILL";
221 #if defined (SIGTRAP) /* trace trap (not reset when caught) */
222 signal_names
[SIGTRAP
] = "SIGTRAP";
225 #if defined (SIGIOT) /* IOT instruction */
226 signal_names
[SIGIOT
] = "SIGIOT";
229 #if defined (SIGABRT) /* Cause current process to dump core. */
230 signal_names
[SIGABRT
] = "SIGABRT";
233 #if defined (SIGEMT) /* EMT instruction */
234 signal_names
[SIGEMT
] = "SIGEMT";
237 #if defined (SIGFPE) /* floating point exception */
238 signal_names
[SIGFPE
] = "SIGFPE";
241 #if defined (SIGKILL) /* kill (cannot be caught or ignored) */
242 signal_names
[SIGKILL
] = "SIGKILL";
245 #if defined (SIGBUS) /* bus error */
246 signal_names
[SIGBUS
] = "SIGBUS";
249 #if defined (SIGSEGV) /* segmentation violation */
250 signal_names
[SIGSEGV
] = "SIGSEGV";
253 #if defined (SIGSYS) /* bad argument to system call */
254 signal_names
[SIGSYS
] = "SIGSYS";
257 #if defined (SIGPIPE) /* write on a pipe with no one to read it */
258 signal_names
[SIGPIPE
] = "SIGPIPE";
261 #if defined (SIGALRM) /* alarm clock */
262 signal_names
[SIGALRM
] = "SIGALRM";
265 #if defined (SIGTERM) /* software termination signal from kill */
266 signal_names
[SIGTERM
] = "SIGTERM";
269 #if defined (SIGURG) /* urgent condition on IO channel */
270 signal_names
[SIGURG
] = "SIGURG";
273 #if defined (SIGSTOP) /* sendable stop signal not from tty */
274 signal_names
[SIGSTOP
] = "SIGSTOP";
277 #if defined (SIGTSTP) /* stop signal from tty */
278 signal_names
[SIGTSTP
] = "SIGTSTP";
281 #if defined (SIGCONT) /* continue a stopped process */
282 signal_names
[SIGCONT
] = "SIGCONT";
285 #if defined (SIGCHLD) /* to parent on child stop or exit */
286 signal_names
[SIGCHLD
] = "SIGCHLD";
289 #if defined (SIGTTIN) /* to readers pgrp upon background tty read */
290 signal_names
[SIGTTIN
] = "SIGTTIN";
293 #if defined (SIGTTOU) /* like TTIN for output if (tp->t_local<OSTOP) */
294 signal_names
[SIGTTOU
] = "SIGTTOU";
297 #if defined (SIGIO) /* input/output possible signal */
298 signal_names
[SIGIO
] = "SIGIO";
301 #if defined (SIGXCPU) /* exceeded CPU time limit */
302 signal_names
[SIGXCPU
] = "SIGXCPU";
305 #if defined (SIGXFSZ) /* exceeded file size limit */
306 signal_names
[SIGXFSZ
] = "SIGXFSZ";
309 #if defined (SIGVTALRM) /* virtual time alarm */
310 signal_names
[SIGVTALRM
] = "SIGVTALRM";
313 #if defined (SIGPROF) /* profiling time alarm */
314 signal_names
[SIGPROF
] = "SIGPROF";
317 #if defined (SIGWINCH) /* window changed */
318 signal_names
[SIGWINCH
] = "SIGWINCH";
322 #if defined (SIGINFO) && !defined (_SEQUENT_) /* information request */
323 signal_names
[SIGINFO
] = "SIGINFO";
326 #if defined (SIGUSR1) /* user defined signal 1 */
327 signal_names
[SIGUSR1
] = "SIGUSR1";
330 #if defined (SIGUSR2) /* user defined signal 2 */
331 signal_names
[SIGUSR2
] = "SIGUSR2";
334 #if defined (SIGKILLTHR) /* BeOS: Kill Thread */
335 signal_names
[SIGKILLTHR
] = "SIGKILLTHR";
338 for (i
= 0; i
< NSIG
; i
++)
339 if (signal_names
[i
] == (char *)NULL
)
341 signal_names
[i
] = (char *)malloc (18);
342 sprintf (signal_names
[i
], "SIGJUNK(%d)", i
);
345 signal_names
[NSIG
] = "DEBUG";
349 write_signames (stream
)
354 fprintf (stream
, "/* This file was automatically created by %s.\n",
356 fprintf (stream
, " Do not edit. Edit support/mksignames.c instead. */\n\n");
358 "/* A translation list so we can be polite to our users. */\n");
359 fprintf (stream
, "char *signal_names[NSIG + 2] = {\n");
361 for (i
= 0; i
<= NSIG
; i
++)
362 fprintf (stream
, " \"%s\",\n", signal_names
[i
]);
364 fprintf (stream
, " (char *)0x0,\n");
365 fprintf (stream
, "};\n");
380 stream_name
= "stdout";
385 stream_name
= argv
[1];
386 stream
= fopen (stream_name
, "w");
390 fprintf (stderr
, "Usage: %s [output-file]\n", progname
);
396 fprintf (stderr
, "%s: %s: cannot open for writing\n",
397 progname
, stream_name
);
401 initialize_signames ();
402 write_signames (stream
);