]>
git.ipfire.org Git - thirdparty/bash.git/blob - signames.c
f5216d5aefa28b8bfb0daa06093b5ab63ebf55ea
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
];
39 initialize_signames ()
43 for (i
= 1; i
< sizeof(signal_names
)/sizeof(signal_names
[0]); i
++)
44 signal_names
[i
] = (char *)NULL
;
46 /* `signal' 0 is what we do on exit. */
47 signal_names
[0] = "EXIT";
49 /* Place signal names which can be aliases for more common signal
50 names first. This allows (for example) SIGEMT to overwrite SIGGRANT. */
51 #if defined (SIGGRANT) /* HFT monitor mode granted */
52 signal_names
[SIGGRANT
] = "SIGGRANT";
55 #if defined (SIGRETRACT) /* HFT monitor mode retracted */
56 signal_names
[SIGRETRACT
] = "SIGRETRACT";
59 #if defined (SIGHUP) /* hangup */
60 signal_names
[SIGHUP
] = "SIGHUP";
63 #if defined (SIGINT) /* interrupt */
64 signal_names
[SIGINT
] = "SIGINT";
67 #if defined (SIGQUIT) /* quit */
68 signal_names
[SIGQUIT
] = "SIGQUIT";
71 #if defined (SIGILL) /* illegal instruction (not reset when caught) */
72 signal_names
[SIGILL
] = "SIGILL";
75 #if defined (SIGTRAP) /* trace trap (not reset when caught) */
76 signal_names
[SIGTRAP
] = "SIGTRAP";
79 #if defined (SIGABRT) /* Cause current process to dump core. */
80 signal_names
[SIGABRT
] = "SIGABRT";
83 #if defined (SIGIOT) /* IOT instruction */
84 signal_names
[SIGIOT
] = "SIGIOT";
87 #if defined (SIGEMT) /* EMT instruction */
88 signal_names
[SIGEMT
] = "SIGEMT";
91 #if defined (SIGFPE) /* floating point exception */
92 signal_names
[SIGFPE
] = "SIGFPE";
95 #if defined (SIGKILL) /* kill (cannot be caught or ignored) */
96 signal_names
[SIGKILL
] = "SIGKILL";
99 #if defined (SIGBUS) /* bus error */
100 signal_names
[SIGBUS
] = "SIGBUS";
103 #if defined (SIGSEGV) /* segmentation violation */
104 signal_names
[SIGSEGV
] = "SIGSEGV";
107 #if defined (SIGSYS) /* bad argument to system call */
108 signal_names
[SIGSYS
] = "SIGSYS";
111 #if defined (SIGPIPE) /* write on a pipe with no one to read it */
112 signal_names
[SIGPIPE
] = "SIGPIPE";
115 #if defined (SIGALRM) /* alarm clock */
116 signal_names
[SIGALRM
] = "SIGALRM";
119 #if defined (SIGTERM) /* software termination signal from kill */
120 signal_names
[SIGTERM
] = "SIGTERM";
123 #if defined (SIGCLD) /* Like SIGCHLD. */
124 signal_names
[SIGCLD
] = "SIGCLD";
127 #if defined (SIGPWR) /* Magic thing for some machines. */
128 signal_names
[SIGPWR
] = "SIGPWR";
131 #if defined (SIGPOLL) /* For keyboard input? */
132 signal_names
[SIGPOLL
] = "SIGPOLL";
135 #if defined (SIGURG) /* urgent condition on IO channel */
136 signal_names
[SIGURG
] = "SIGURG";
139 #if defined (SIGSTOP) /* sendable stop signal not from tty */
140 signal_names
[SIGSTOP
] = "SIGSTOP";
143 #if defined (SIGTSTP) /* stop signal from tty */
144 signal_names
[SIGTSTP
] = "SIGTSTP";
147 #if defined (SIGCONT) /* continue a stopped process */
148 signal_names
[SIGCONT
] = "SIGCONT";
151 #if defined (SIGCHLD) /* to parent on child stop or exit */
152 signal_names
[SIGCHLD
] = "SIGCHLD";
155 #if defined (SIGTTIN) /* to readers pgrp upon background tty read */
156 signal_names
[SIGTTIN
] = "SIGTTIN";
159 #if defined (SIGTTOU) /* like TTIN for output if (tp->t_local<OSTOP) */
160 signal_names
[SIGTTOU
] = "SIGTTOU";
163 #if defined (SIGIO) /* input/output possible signal */
164 signal_names
[SIGIO
] = "SIGIO";
167 #if defined (SIGXCPU) /* exceeded CPU time limit */
168 signal_names
[SIGXCPU
] = "SIGXCPU";
171 #if defined (SIGXFSZ) /* exceeded file size limit */
172 signal_names
[SIGXFSZ
] = "SIGXFSZ";
175 #if defined (SIGVTALRM) /* virtual time alarm */
176 signal_names
[SIGVTALRM
] = "SIGVTALRM";
179 #if defined (SIGPROF) /* profiling time alarm */
180 signal_names
[SIGPROF
] = "SIGPROF";
183 #if defined (SIGWINCH) /* window changed */
184 signal_names
[SIGWINCH
] = "SIGWINCH";
187 #if defined (SIGLOST) /* resource lost (eg, record-lock lost) */
188 signal_names
[SIGLOST
] = "SIGLOST";
191 #if defined (SIGUSR1) /* user defined signal 1 */
192 signal_names
[SIGUSR1
] = "SIGUSR1";
195 #if defined (SIGUSR2) /* user defined signal 2 */
196 signal_names
[SIGUSR2
] = "SIGUSR2";
199 #if defined (SIGMSG) /* HFT input data pending */
200 signal_names
[SIGMSG
] = "SIGMSG";
203 #if defined (SIGPWR) /* power failure imminent (save your data) */
204 signal_names
[SIGPWR
] = "SIGPWR";
207 #if defined (SIGDANGER) /* system crash imminent */
208 signal_names
[SIGDANGER
] = "SIGDANGER";
211 #if defined (SIGMIGRATE) /* migrate process to another CPU */
212 signal_names
[SIGMIGRATE
] = "SIGMIGRATE";
215 #if defined (SIGPRE) /* programming error */
216 signal_names
[SIGPRE
] = "SIGPRE";
219 #if defined (SIGSOUND) /* HFT sound sequence has completed */
220 signal_names
[SIGSOUND
] = "SIGSOUND";
223 #if defined (SIGWINDOW)
224 signal_names
[SIGWINDOW
] = "SIGWINDOW";
228 signal_names
[SIGDIL
] = "SIGDIL";
231 #if defined (SIGSAK) /* Secure Attention Key */
232 signal_names
[SIGSAK
] = "SIGSAK";
235 for (i
= 0; i
< NSIG
; i
++)
236 if (signal_names
[i
] == (char *)NULL
)
238 signal_names
[i
] = (char *)malloc (18);
239 sprintf (signal_names
[i
], "SIGJUNK(%d)", i
);
243 write_signames (stream
)
248 fprintf (stream
, "/* This file was automatically created by %s.\n",
250 fprintf (stream
, " Do not edit. Edit signames.c instead. */\n\n");
252 "/* A translation list so we can be polite to our users. */\n");
253 fprintf (stream
, "char *signal_names[NSIG + 2] = {\n");
255 for (i
= 0; i
< NSIG
; i
++)
256 fprintf (stream
, " \"%s\",\n", signal_names
[i
]);
258 fprintf (stream
, " (char *)0x0,\n");
259 fprintf (stream
, "};\n");
273 stream_name
= "stdout";
278 stream_name
= argv
[1];
279 stream
= fopen (stream_name
, "w");
283 fprintf (stderr
, "Usage: %s [output-file]\n", progname
);
289 fprintf (stderr
, "%s: %s Cannot be opened or written to.\n",
290 progname
, stream_name
);
294 initialize_signames ();
295 write_signames (stream
);