]>
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 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) SIGEMT to overwrite SIGGRANT. */
52 #if defined (SIGGRANT) /* HFT monitor mode granted */
53 signal_names
[SIGGRANT
] = "SIGGRANT";
56 #if defined (SIGRETRACT) /* HFT monitor mode retracted */
57 signal_names
[SIGRETRACT
] = "SIGRETRACT";
60 #if defined (SIGHUP) /* hangup */
61 signal_names
[SIGHUP
] = "SIGHUP";
64 #if defined (SIGINT) /* interrupt */
65 signal_names
[SIGINT
] = "SIGINT";
68 #if defined (SIGQUIT) /* quit */
69 signal_names
[SIGQUIT
] = "SIGQUIT";
72 #if defined (SIGILL) /* illegal instruction (not reset when caught) */
73 signal_names
[SIGILL
] = "SIGILL";
76 #if defined (SIGTRAP) /* trace trap (not reset when caught) */
77 signal_names
[SIGTRAP
] = "SIGTRAP";
80 #if defined (SIGABRT) /* Cause current process to dump core. */
81 signal_names
[SIGABRT
] = "SIGABRT";
84 #if defined (SIGIOT) /* IOT instruction */
85 signal_names
[SIGIOT
] = "SIGIOT";
88 #if defined (SIGEMT) /* EMT instruction */
89 signal_names
[SIGEMT
] = "SIGEMT";
92 #if defined (SIGFPE) /* floating point exception */
93 signal_names
[SIGFPE
] = "SIGFPE";
96 #if defined (SIGKILL) /* kill (cannot be caught or ignored) */
97 signal_names
[SIGKILL
] = "SIGKILL";
100 #if defined (SIGBUS) /* bus error */
101 signal_names
[SIGBUS
] = "SIGBUS";
104 #if defined (SIGSEGV) /* segmentation violation */
105 signal_names
[SIGSEGV
] = "SIGSEGV";
108 #if defined (SIGSYS) /* bad argument to system call */
109 signal_names
[SIGSYS
] = "SIGSYS";
112 #if defined (SIGPIPE) /* write on a pipe with no one to read it */
113 signal_names
[SIGPIPE
] = "SIGPIPE";
116 #if defined (SIGALRM) /* alarm clock */
117 signal_names
[SIGALRM
] = "SIGALRM";
120 #if defined (SIGTERM) /* software termination signal from kill */
121 signal_names
[SIGTERM
] = "SIGTERM";
124 #if defined (SIGCLD) /* Like SIGCHLD. */
125 signal_names
[SIGCLD
] = "SIGCLD";
128 #if defined (SIGPWR) /* Magic thing for some machines. */
129 signal_names
[SIGPWR
] = "SIGPWR";
132 #if defined (SIGPOLL) /* For keyboard input? */
133 signal_names
[SIGPOLL
] = "SIGPOLL";
136 #if defined (SIGURG) /* urgent condition on IO channel */
137 signal_names
[SIGURG
] = "SIGURG";
140 #if defined (SIGSTOP) /* sendable stop signal not from tty */
141 signal_names
[SIGSTOP
] = "SIGSTOP";
144 #if defined (SIGTSTP) /* stop signal from tty */
145 signal_names
[SIGTSTP
] = "SIGTSTP";
148 #if defined (SIGCONT) /* continue a stopped process */
149 signal_names
[SIGCONT
] = "SIGCONT";
152 #if defined (SIGCHLD) /* to parent on child stop or exit */
153 signal_names
[SIGCHLD
] = "SIGCHLD";
156 #if defined (SIGTTIN) /* to readers pgrp upon background tty read */
157 signal_names
[SIGTTIN
] = "SIGTTIN";
160 #if defined (SIGTTOU) /* like TTIN for output if (tp->t_local<OSTOP) */
161 signal_names
[SIGTTOU
] = "SIGTTOU";
164 #if defined (SIGIO) /* input/output possible signal */
165 signal_names
[SIGIO
] = "SIGIO";
168 #if defined (SIGXCPU) /* exceeded CPU time limit */
169 signal_names
[SIGXCPU
] = "SIGXCPU";
172 #if defined (SIGXFSZ) /* exceeded file size limit */
173 signal_names
[SIGXFSZ
] = "SIGXFSZ";
176 #if defined (SIGVTALRM) /* virtual time alarm */
177 signal_names
[SIGVTALRM
] = "SIGVTALRM";
180 #if defined (SIGPROF) /* profiling time alarm */
181 signal_names
[SIGPROF
] = "SIGPROF";
184 #if defined (SIGWINCH) /* window changed */
185 signal_names
[SIGWINCH
] = "SIGWINCH";
188 #if defined (SIGLOST) /* resource lost (eg, record-lock lost) */
189 signal_names
[SIGLOST
] = "SIGLOST";
192 #if defined (SIGUSR1) /* user defined signal 1 */
193 signal_names
[SIGUSR1
] = "SIGUSR1";
196 #if defined (SIGUSR2) /* user defined signal 2 */
197 signal_names
[SIGUSR2
] = "SIGUSR2";
200 #if defined (SIGMSG) /* HFT input data pending */
201 signal_names
[SIGMSG
] = "SIGMSG";
204 #if defined (SIGPWR) /* power failure imminent (save your data) */
205 signal_names
[SIGPWR
] = "SIGPWR";
208 #if defined (SIGDANGER) /* system crash imminent */
209 signal_names
[SIGDANGER
] = "SIGDANGER";
212 #if defined (SIGMIGRATE) /* migrate process to another CPU */
213 signal_names
[SIGMIGRATE
] = "SIGMIGRATE";
216 #if defined (SIGPRE) /* programming error */
217 signal_names
[SIGPRE
] = "SIGPRE";
220 #if defined (SIGSOUND) /* HFT sound sequence has completed */
221 signal_names
[SIGSOUND
] = "SIGSOUND";
224 #if defined (SIGWINDOW)
225 signal_names
[SIGWINDOW
] = "SIGWINDOW";
229 signal_names
[SIGDIL
] = "SIGDIL";
232 #if defined (SIGSAK) /* Secure Attention Key */
233 signal_names
[SIGSAK
] = "SIGSAK";
236 for (i
= 0; i
< NSIG
; i
++)
237 if (signal_names
[i
] == (char *)NULL
)
239 signal_names
[i
] = (char *)malloc (18);
240 sprintf (signal_names
[i
], "SIGJUNK(%d)", i
);
243 signal_names
[NSIG
] = "DEBUG";
247 write_signames (stream
)
252 fprintf (stream
, "/* This file was automatically created by %s.\n",
254 fprintf (stream
, " Do not edit. Edit support/mksignames.c instead. */\n\n");
256 "/* A translation list so we can be polite to our users. */\n");
257 fprintf (stream
, "char *signal_names[NSIG + 2] = {\n");
259 for (i
= 0; i
<= NSIG
; i
++)
260 fprintf (stream
, " \"%s\",\n", signal_names
[i
]);
262 fprintf (stream
, " (char *)0x0,\n");
263 fprintf (stream
, "};\n");
278 stream_name
= "stdout";
283 stream_name
= argv
[1];
284 stream
= fopen (stream_name
, "w");
288 fprintf (stderr
, "Usage: %s [output-file]\n", progname
);
294 fprintf (stderr
, "%s: %s: cannot open for writing\n",
295 progname
, stream_name
);
299 initialize_signames ();
300 write_signames (stream
);