]>
Commit | Line | Data |
---|---|---|
726f6388 JA |
1 | /* signames.c -- Create and write `signames.h', which contains an array of |
2 | signal names. */ | |
3 | ||
4 | /* Copyright (C) 1992 Free Software Foundation, Inc. | |
5 | ||
6 | This file is part of GNU Bash, the Bourne Again SHell. | |
7 | ||
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 | |
11 | version. | |
12 | ||
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 | |
16 | for more details. | |
17 | ||
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. */ | |
21 | ||
22 | #include <stdio.h> | |
23 | #include <sys/types.h> | |
24 | #include <signal.h> | |
25 | #if defined (HAVE_STDLIB_H) | |
26 | # include <stdlib.h> | |
27 | #else | |
28 | # include "ansi_stdlib.h" | |
29 | #endif /* HAVE_STDLIB_H */ | |
30 | ||
31 | #if !defined (NSIG) | |
32 | # define NSIG 64 | |
33 | #endif | |
34 | ||
35 | char *signal_names[2 * NSIG]; | |
36 | ||
37 | char *progname; | |
38 | ||
ccc6cda3 | 39 | void |
726f6388 JA |
40 | initialize_signames () |
41 | { | |
42 | register int i; | |
43 | ||
44 | for (i = 1; i < sizeof(signal_names)/sizeof(signal_names[0]); i++) | |
45 | signal_names[i] = (char *)NULL; | |
46 | ||
47 | /* `signal' 0 is what we do on exit. */ | |
48 | signal_names[0] = "EXIT"; | |
49 | ||
50 | /* Place signal names which can be aliases for more common signal | |
d166f048 JA |
51 | names first. This allows (for example) SIGABRT to overwrite SIGLOST. */ |
52 | /* AIX */ | |
53 | #if defined (SIGLOST) /* resource lost (eg, record-lock lost) */ | |
54 | signal_names[SIGLOST] = "SIGLOST"; | |
55 | #endif | |
56 | ||
57 | #if defined (SIGMSG) /* HFT input data pending */ | |
58 | signal_names[SIGMSG] = "SIGMSG"; | |
59 | #endif | |
60 | ||
61 | #if defined (SIGDANGER) /* system crash imminent */ | |
62 | signal_names[SIGDANGER] = "SIGDANGER"; | |
63 | #endif | |
64 | ||
65 | #if defined (SIGMIGRATE) /* migrate process to another CPU */ | |
66 | signal_names[SIGMIGRATE] = "SIGMIGRATE"; | |
67 | #endif | |
68 | ||
69 | #if defined (SIGPRE) /* programming error */ | |
70 | signal_names[SIGPRE] = "SIGPRE"; | |
71 | #endif | |
72 | ||
73 | #if defined (SIGVIRT) /* AIX virtual time alarm */ | |
74 | signal_names[SIGVIRT] = "SIGVIRT"; | |
75 | #endif | |
76 | ||
77 | #if defined (SIGALRM1) /* m:n condition variables */ | |
78 | signal_names[SIGALRM1] = "SIGALRM1"; | |
79 | #endif | |
80 | ||
81 | #if defined (SIGWAITING) /* m:n scheduling */ | |
82 | signal_names[SIGWAITING] = "SIGWAITING"; | |
83 | #endif | |
84 | ||
726f6388 JA |
85 | #if defined (SIGGRANT) /* HFT monitor mode granted */ |
86 | signal_names[SIGGRANT] = "SIGGRANT"; | |
87 | #endif | |
88 | ||
d166f048 JA |
89 | #if defined (SIGKAP) /* keep alive poll from native keyboard */ |
90 | signal_names[SIGKAP] = "SIGKAP"; | |
91 | #endif | |
92 | ||
726f6388 JA |
93 | #if defined (SIGRETRACT) /* HFT monitor mode retracted */ |
94 | signal_names[SIGRETRACT] = "SIGRETRACT"; | |
95 | #endif | |
96 | ||
d166f048 JA |
97 | #if defined (SIGSOUND) /* HFT sound sequence has completed */ |
98 | signal_names[SIGSOUND] = "SIGSOUND"; | |
99 | #endif | |
100 | ||
101 | #if defined (SIGSAK) /* Secure Attention Key */ | |
102 | signal_names[SIGSAK] = "SIGSAK"; | |
103 | #endif | |
104 | ||
105 | /* SunOS5 */ | |
106 | #if defined (SIGLWP) /* special signal used by thread library */ | |
107 | signal_names[SIGLWP] = "SIGLWP"; | |
108 | #endif | |
109 | ||
110 | #if defined (SIGFREEZE) /* special signal used by CPR */ | |
111 | signal_names[SIGFREEZE] = "SIGFREEZE"; | |
112 | #endif | |
113 | ||
114 | #if defined (SIGTHAW) /* special signal used by CPR */ | |
115 | signal_names[SIGTHAW] = "SIGTHAW"; | |
116 | #endif | |
117 | ||
118 | #if defined (SIGCANCEL) /* thread cancellation signal used by libthread */ | |
119 | signal_names[SIGCANCEL] = "SIGCANCEL"; | |
120 | #endif | |
121 | ||
122 | /* HP-UX */ | |
123 | #if defined (SIGDIL) /* DIL signal (?) */ | |
124 | signal_names[SIGDIL] = "SIGDIL"; | |
125 | #endif | |
126 | ||
127 | /* System V */ | |
128 | #if defined (SIGCLD) /* Like SIGCHLD. */ | |
129 | signal_names[SIGCLD] = "SIGCLD"; | |
130 | #endif | |
131 | ||
132 | #if defined (SIGPWR) /* power state indication */ | |
133 | signal_names[SIGPWR] = "SIGPWR"; | |
134 | #endif | |
135 | ||
136 | #if defined (SIGPOLL) /* Pollable event (for streams) */ | |
137 | signal_names[SIGPOLL] = "SIGPOLL"; | |
138 | #endif | |
139 | ||
140 | /* Unknown */ | |
141 | #if defined (SIGWINDOW) | |
142 | signal_names[SIGWINDOW] = "SIGWINDOW"; | |
143 | #endif | |
144 | ||
145 | /* Common */ | |
726f6388 JA |
146 | #if defined (SIGHUP) /* hangup */ |
147 | signal_names[SIGHUP] = "SIGHUP"; | |
148 | #endif | |
149 | ||
150 | #if defined (SIGINT) /* interrupt */ | |
151 | signal_names[SIGINT] = "SIGINT"; | |
152 | #endif | |
153 | ||
154 | #if defined (SIGQUIT) /* quit */ | |
155 | signal_names[SIGQUIT] = "SIGQUIT"; | |
156 | #endif | |
157 | ||
158 | #if defined (SIGILL) /* illegal instruction (not reset when caught) */ | |
159 | signal_names[SIGILL] = "SIGILL"; | |
160 | #endif | |
161 | ||
162 | #if defined (SIGTRAP) /* trace trap (not reset when caught) */ | |
163 | signal_names[SIGTRAP] = "SIGTRAP"; | |
164 | #endif | |
165 | ||
726f6388 JA |
166 | #if defined (SIGIOT) /* IOT instruction */ |
167 | signal_names[SIGIOT] = "SIGIOT"; | |
168 | #endif | |
169 | ||
d166f048 JA |
170 | #if defined (SIGABRT) /* Cause current process to dump core. */ |
171 | signal_names[SIGABRT] = "SIGABRT"; | |
172 | #endif | |
173 | ||
726f6388 JA |
174 | #if defined (SIGEMT) /* EMT instruction */ |
175 | signal_names[SIGEMT] = "SIGEMT"; | |
176 | #endif | |
177 | ||
178 | #if defined (SIGFPE) /* floating point exception */ | |
179 | signal_names[SIGFPE] = "SIGFPE"; | |
180 | #endif | |
181 | ||
182 | #if defined (SIGKILL) /* kill (cannot be caught or ignored) */ | |
183 | signal_names[SIGKILL] = "SIGKILL"; | |
184 | #endif | |
185 | ||
186 | #if defined (SIGBUS) /* bus error */ | |
187 | signal_names[SIGBUS] = "SIGBUS"; | |
188 | #endif | |
189 | ||
190 | #if defined (SIGSEGV) /* segmentation violation */ | |
191 | signal_names[SIGSEGV] = "SIGSEGV"; | |
192 | #endif | |
193 | ||
194 | #if defined (SIGSYS) /* bad argument to system call */ | |
195 | signal_names[SIGSYS] = "SIGSYS"; | |
196 | #endif | |
197 | ||
198 | #if defined (SIGPIPE) /* write on a pipe with no one to read it */ | |
199 | signal_names[SIGPIPE] = "SIGPIPE"; | |
200 | #endif | |
201 | ||
202 | #if defined (SIGALRM) /* alarm clock */ | |
203 | signal_names[SIGALRM] = "SIGALRM"; | |
204 | #endif | |
205 | ||
206 | #if defined (SIGTERM) /* software termination signal from kill */ | |
207 | signal_names[SIGTERM] = "SIGTERM"; | |
208 | #endif | |
209 | ||
726f6388 JA |
210 | #if defined (SIGURG) /* urgent condition on IO channel */ |
211 | signal_names[SIGURG] = "SIGURG"; | |
212 | #endif | |
213 | ||
214 | #if defined (SIGSTOP) /* sendable stop signal not from tty */ | |
215 | signal_names[SIGSTOP] = "SIGSTOP"; | |
216 | #endif | |
217 | ||
218 | #if defined (SIGTSTP) /* stop signal from tty */ | |
219 | signal_names[SIGTSTP] = "SIGTSTP"; | |
220 | #endif | |
221 | ||
222 | #if defined (SIGCONT) /* continue a stopped process */ | |
223 | signal_names[SIGCONT] = "SIGCONT"; | |
224 | #endif | |
225 | ||
226 | #if defined (SIGCHLD) /* to parent on child stop or exit */ | |
227 | signal_names[SIGCHLD] = "SIGCHLD"; | |
228 | #endif | |
229 | ||
230 | #if defined (SIGTTIN) /* to readers pgrp upon background tty read */ | |
231 | signal_names[SIGTTIN] = "SIGTTIN"; | |
232 | #endif | |
233 | ||
234 | #if defined (SIGTTOU) /* like TTIN for output if (tp->t_local<OSTOP) */ | |
235 | signal_names[SIGTTOU] = "SIGTTOU"; | |
236 | #endif | |
237 | ||
238 | #if defined (SIGIO) /* input/output possible signal */ | |
239 | signal_names[SIGIO] = "SIGIO"; | |
240 | #endif | |
241 | ||
242 | #if defined (SIGXCPU) /* exceeded CPU time limit */ | |
243 | signal_names[SIGXCPU] = "SIGXCPU"; | |
244 | #endif | |
245 | ||
246 | #if defined (SIGXFSZ) /* exceeded file size limit */ | |
247 | signal_names[SIGXFSZ] = "SIGXFSZ"; | |
248 | #endif | |
249 | ||
250 | #if defined (SIGVTALRM) /* virtual time alarm */ | |
251 | signal_names[SIGVTALRM] = "SIGVTALRM"; | |
252 | #endif | |
253 | ||
254 | #if defined (SIGPROF) /* profiling time alarm */ | |
255 | signal_names[SIGPROF] = "SIGPROF"; | |
256 | #endif | |
257 | ||
258 | #if defined (SIGWINCH) /* window changed */ | |
259 | signal_names[SIGWINCH] = "SIGWINCH"; | |
260 | #endif | |
261 | ||
d166f048 | 262 | /* 4.4 BSD */ |
b72432fd | 263 | #if defined (SIGINFO) && !defined (_SEQUENT_) /* information request */ |
d166f048 | 264 | signal_names[SIGINFO] = "SIGINFO"; |
726f6388 JA |
265 | #endif |
266 | ||
267 | #if defined (SIGUSR1) /* user defined signal 1 */ | |
268 | signal_names[SIGUSR1] = "SIGUSR1"; | |
269 | #endif | |
270 | ||
271 | #if defined (SIGUSR2) /* user defined signal 2 */ | |
272 | signal_names[SIGUSR2] = "SIGUSR2"; | |
273 | #endif | |
274 | ||
b72432fd JA |
275 | #if defined (SIGKILLTHR) /* BeOS: Kill Thread */ |
276 | signal_names[SIGKILLTHR] = "SIGKILLTHR"; | |
277 | #endif | |
278 | ||
726f6388 JA |
279 | for (i = 0; i < NSIG; i++) |
280 | if (signal_names[i] == (char *)NULL) | |
281 | { | |
282 | signal_names[i] = (char *)malloc (18); | |
283 | sprintf (signal_names[i], "SIGJUNK(%d)", i); | |
284 | } | |
ccc6cda3 JA |
285 | |
286 | signal_names[NSIG] = "DEBUG"; | |
726f6388 JA |
287 | } |
288 | ||
ccc6cda3 | 289 | void |
726f6388 JA |
290 | write_signames (stream) |
291 | FILE *stream; | |
292 | { | |
293 | register int i; | |
294 | ||
295 | fprintf (stream, "/* This file was automatically created by %s.\n", | |
296 | progname); | |
ccc6cda3 | 297 | fprintf (stream, " Do not edit. Edit support/mksignames.c instead. */\n\n"); |
726f6388 JA |
298 | fprintf (stream, |
299 | "/* A translation list so we can be polite to our users. */\n"); | |
300 | fprintf (stream, "char *signal_names[NSIG + 2] = {\n"); | |
301 | ||
ccc6cda3 | 302 | for (i = 0; i <= NSIG; i++) |
726f6388 JA |
303 | fprintf (stream, " \"%s\",\n", signal_names[i]); |
304 | ||
305 | fprintf (stream, " (char *)0x0,\n"); | |
306 | fprintf (stream, "};\n"); | |
307 | } | |
308 | ||
ccc6cda3 | 309 | int |
726f6388 JA |
310 | main (argc, argv) |
311 | int argc; | |
312 | char **argv; | |
313 | { | |
314 | char *stream_name; | |
315 | FILE *stream; | |
316 | ||
317 | progname = argv[0]; | |
318 | ||
319 | if (argc == 1) | |
320 | { | |
321 | stream_name = "stdout"; | |
322 | stream = stdout; | |
323 | } | |
324 | else if (argc == 2) | |
325 | { | |
326 | stream_name = argv[1]; | |
327 | stream = fopen (stream_name, "w"); | |
328 | } | |
329 | else | |
330 | { | |
331 | fprintf (stderr, "Usage: %s [output-file]\n", progname); | |
332 | exit (1); | |
333 | } | |
334 | ||
335 | if (!stream) | |
336 | { | |
ccc6cda3 | 337 | fprintf (stderr, "%s: %s: cannot open for writing\n", |
726f6388 JA |
338 | progname, stream_name); |
339 | exit (2); | |
340 | } | |
341 | ||
342 | initialize_signames (); | |
343 | write_signames (stream); | |
344 | exit (0); | |
345 | } |