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 1, 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, 675 Mass Ave, Cambridge, MA 02139, 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];
40 initialize_signames ()
44 for (i = 1; i < sizeof(signal_names)/sizeof(signal_names[0]); i++)
45 signal_names[i] = (char *)NULL;
47 /* `signal' 0 is what we do on exit. */
48 signal_names[0] = "EXIT";
50 /* Place signal names which can be aliases for more common signal
51 names first. This allows (for example) SIGABRT to overwrite SIGLOST. */
53 #if defined (SIGLOST) /* resource lost (eg, record-lock lost) */
54 signal_names[SIGLOST] = "SIGLOST";
57 #if defined (SIGMSG) /* HFT input data pending */
58 signal_names[SIGMSG] = "SIGMSG";
61 #if defined (SIGDANGER) /* system crash imminent */
62 signal_names[SIGDANGER] = "SIGDANGER";
65 #if defined (SIGMIGRATE) /* migrate process to another CPU */
66 signal_names[SIGMIGRATE] = "SIGMIGRATE";
69 #if defined (SIGPRE) /* programming error */
70 signal_names[SIGPRE] = "SIGPRE";
73 #if defined (SIGVIRT) /* AIX virtual time alarm */
74 signal_names[SIGVIRT] = "SIGVIRT";
77 #if defined (SIGALRM1) /* m:n condition variables */
78 signal_names[SIGALRM1] = "SIGALRM1";
81 #if defined (SIGWAITING) /* m:n scheduling */
82 signal_names[SIGWAITING] = "SIGWAITING";
85 #if defined (SIGGRANT) /* HFT monitor mode granted */
86 signal_names[SIGGRANT] = "SIGGRANT";
89 #if defined (SIGKAP) /* keep alive poll from native keyboard */
90 signal_names[SIGKAP] = "SIGKAP";
93 #if defined (SIGRETRACT) /* HFT monitor mode retracted */
94 signal_names[SIGRETRACT] = "SIGRETRACT";
97 #if defined (SIGSOUND) /* HFT sound sequence has completed */
98 signal_names[SIGSOUND] = "SIGSOUND";
101 #if defined (SIGSAK) /* Secure Attention Key */
102 signal_names[SIGSAK] = "SIGSAK";
106 #if defined (SIGLWP) /* special signal used by thread library */
107 signal_names[SIGLWP] = "SIGLWP";
110 #if defined (SIGFREEZE) /* special signal used by CPR */
111 signal_names[SIGFREEZE] = "SIGFREEZE";
114 #if defined (SIGTHAW) /* special signal used by CPR */
115 signal_names[SIGTHAW] = "SIGTHAW";
118 #if defined (SIGCANCEL) /* thread cancellation signal used by libthread */
119 signal_names[SIGCANCEL] = "SIGCANCEL";
123 #if defined (SIGDIL) /* DIL signal (?) */
124 signal_names[SIGDIL] = "SIGDIL";
128 #if defined (SIGCLD) /* Like SIGCHLD. */
129 signal_names[SIGCLD] = "SIGCLD";
132 #if defined (SIGPWR) /* power state indication */
133 signal_names[SIGPWR] = "SIGPWR";
136 #if defined (SIGPOLL) /* Pollable event (for streams) */
137 signal_names[SIGPOLL] = "SIGPOLL";
141 #if defined (SIGWINDOW)
142 signal_names[SIGWINDOW] = "SIGWINDOW";
146 #if defined (SIGHUP) /* hangup */
147 signal_names[SIGHUP] = "SIGHUP";
150 #if defined (SIGINT) /* interrupt */
151 signal_names[SIGINT] = "SIGINT";
154 #if defined (SIGQUIT) /* quit */
155 signal_names[SIGQUIT] = "SIGQUIT";
158 #if defined (SIGILL) /* illegal instruction (not reset when caught) */
159 signal_names[SIGILL] = "SIGILL";
162 #if defined (SIGTRAP) /* trace trap (not reset when caught) */
163 signal_names[SIGTRAP] = "SIGTRAP";
166 #if defined (SIGIOT) /* IOT instruction */
167 signal_names[SIGIOT] = "SIGIOT";
170 #if defined (SIGABRT) /* Cause current process to dump core. */
171 signal_names[SIGABRT] = "SIGABRT";
174 #if defined (SIGEMT) /* EMT instruction */
175 signal_names[SIGEMT] = "SIGEMT";
178 #if defined (SIGFPE) /* floating point exception */
179 signal_names[SIGFPE] = "SIGFPE";
182 #if defined (SIGKILL) /* kill (cannot be caught or ignored) */
183 signal_names[SIGKILL] = "SIGKILL";
186 #if defined (SIGBUS) /* bus error */
187 signal_names[SIGBUS] = "SIGBUS";
190 #if defined (SIGSEGV) /* segmentation violation */
191 signal_names[SIGSEGV] = "SIGSEGV";
194 #if defined (SIGSYS) /* bad argument to system call */
195 signal_names[SIGSYS] = "SIGSYS";
198 #if defined (SIGPIPE) /* write on a pipe with no one to read it */
199 signal_names[SIGPIPE] = "SIGPIPE";
202 #if defined (SIGALRM) /* alarm clock */
203 signal_names[SIGALRM] = "SIGALRM";
206 #if defined (SIGTERM) /* software termination signal from kill */
207 signal_names[SIGTERM] = "SIGTERM";
210 #if defined (SIGURG) /* urgent condition on IO channel */
211 signal_names[SIGURG] = "SIGURG";
214 #if defined (SIGSTOP) /* sendable stop signal not from tty */
215 signal_names[SIGSTOP] = "SIGSTOP";
218 #if defined (SIGTSTP) /* stop signal from tty */
219 signal_names[SIGTSTP] = "SIGTSTP";
222 #if defined (SIGCONT) /* continue a stopped process */
223 signal_names[SIGCONT] = "SIGCONT";
226 #if defined (SIGCHLD) /* to parent on child stop or exit */
227 signal_names[SIGCHLD] = "SIGCHLD";
230 #if defined (SIGTTIN) /* to readers pgrp upon background tty read */
231 signal_names[SIGTTIN] = "SIGTTIN";
234 #if defined (SIGTTOU) /* like TTIN for output if (tp->t_local<OSTOP) */
235 signal_names[SIGTTOU] = "SIGTTOU";
238 #if defined (SIGIO) /* input/output possible signal */
239 signal_names[SIGIO] = "SIGIO";
242 #if defined (SIGXCPU) /* exceeded CPU time limit */
243 signal_names[SIGXCPU] = "SIGXCPU";
246 #if defined (SIGXFSZ) /* exceeded file size limit */
247 signal_names[SIGXFSZ] = "SIGXFSZ";
250 #if defined (SIGVTALRM) /* virtual time alarm */
251 signal_names[SIGVTALRM] = "SIGVTALRM";
254 #if defined (SIGPROF) /* profiling time alarm */
255 signal_names[SIGPROF] = "SIGPROF";
258 #if defined (SIGWINCH) /* window changed */
259 signal_names[SIGWINCH] = "SIGWINCH";
263 #if defined (SIGINFO) /* information request */
264 signal_names[SIGINFO] = "SIGINFO";
267 #if defined (SIGUSR1) /* user defined signal 1 */
268 signal_names[SIGUSR1] = "SIGUSR1";
271 #if defined (SIGUSR2) /* user defined signal 2 */
272 signal_names[SIGUSR2] = "SIGUSR2";
275 for (i = 0; i < NSIG; i++)
276 if (signal_names[i] == (char *)NULL)
278 signal_names[i] = (char *)malloc (18);
279 sprintf (signal_names[i], "SIGJUNK(%d)", i);
282 signal_names[NSIG] = "DEBUG";
286 write_signames (stream)
291 fprintf (stream, "/* This file was automatically created by %s.\n",
293 fprintf (stream, " Do not edit. Edit support/mksignames.c instead. */\n\n");
295 "/* A translation list so we can be polite to our users. */\n");
296 fprintf (stream, "char *signal_names[NSIG + 2] = {\n");
298 for (i = 0; i <= NSIG; i++)
299 fprintf (stream, " \"%s\",\n", signal_names[i]);
301 fprintf (stream, " (char *)0x0,\n");
302 fprintf (stream, "};\n");
317 stream_name = "stdout";
322 stream_name = argv[1];
323 stream = fopen (stream_name, "w");
327 fprintf (stderr, "Usage: %s [output-file]\n", progname);
333 fprintf (stderr, "%s: %s: cannot open for writing\n",
334 progname, stream_name);
338 initialize_signames ();
339 write_signames (stream);