1 /* Convert between signal names and numbers.
2 Copyright (C) 1990 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 1, or (at your option)
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
28 #if SYS_SIGLIST_MISSING
29 /* There is too much variation in Sys V signal numbers and names, so
30 we must initialize them at runtime. */
32 static CONST
char undoc
[] = "unknown signal";
34 char *sys_siglist
[NSIG
];
35 #endif /* SYS_SIGLIST_MISSING */
37 /* Table of abbreviations for signals. Note: A given number can
38 appear more than once with different abbreviations. */
44 static num_abbrev sig_table
[NSIG
*2];
45 /* Number of elements of sig_table used. */
46 static int sig_table_nelts
= 0;
48 /* Enter signal number NUMBER into the tables with ABBREV and NAME. */
50 init_sig (number
, abbrev
, name
)
55 #if SYS_SIGLIST_MISSING
56 sys_siglist
[number
] = name
;
58 sig_table
[sig_table_nelts
].number
= number
;
59 sig_table
[sig_table_nelts
++].abbrev
= abbrev
;
62 static void init_sigs ()
64 #if SYS_SIGLIST_MISSING
67 /* Initialize signal names. */
68 for (i
= 0; i
< NSIG
; i
++)
69 sys_siglist
[i
] = undoc
;
70 #endif /* SYS_SIGLIST_MISSING */
72 /* Initialize signal names. */
74 init_sig (SIGHUP
, "HUP", "Hangup");
77 init_sig (SIGINT
, "INT", "Interrupt");
80 init_sig (SIGQUIT
, "QUIT", "Quit");
83 init_sig (SIGILL
, "ILL", "Illegal Instruction");
86 init_sig (SIGTRAP
, "TRAP", "Trace/breakpoint trap");
88 /* If SIGIOT == SIGABRT, we want to print it as SIGABRT because
89 SIGABRT is in ANSI and POSIX.1 and SIGIOT isn't. */
91 init_sig (SIGABRT
, "ABRT", "Aborted");
94 init_sig (SIGIOT
, "IOT", "IOT trap");
97 init_sig (SIGEMT
, "EMT", "EMT trap");
100 init_sig (SIGFPE
, "FPE", "Floating point exception");
102 #if defined (SIGKILL)
103 init_sig (SIGKILL
, "KILL", "Killed");
106 init_sig (SIGBUS
, "BUS", "Bus error");
108 #if defined (SIGSEGV)
109 init_sig (SIGSEGV
, "SEGV", "Segmentation fault");
112 init_sig (SIGSYS
, "SYS", "Bad system call");
114 #if defined (SIGPIPE)
115 init_sig (SIGPIPE
, "PIPE", "Broken pipe");
117 #if defined (SIGALRM)
118 init_sig (SIGALRM
, "ALRM", "Alarm clock");
120 #if defined (SIGTERM)
121 init_sig (SIGTERM
, "TERM", "Terminated");
123 #if defined (SIGUSR1)
124 init_sig (SIGUSR1
, "USR1", "User defined signal 1");
126 #if defined (SIGUSR2)
127 init_sig (SIGUSR2
, "USR2", "User defined signal 2");
129 /* If SIGCLD == SIGCHLD, we want to print it as SIGCHLD because that
130 is what is in POSIX.1. */
131 #if defined (SIGCHLD)
132 init_sig (SIGCHLD
, "CHLD", "Child exited");
135 init_sig (SIGCLD
, "CLD", "Child exited");
138 init_sig (SIGPWR
, "PWR", "Power failure");
140 #if defined (SIGTSTP)
141 init_sig (SIGTSTP
, "TSTP", "Stopped");
143 #if defined (SIGTTIN)
144 init_sig (SIGTTIN
, "TTIN", "Stopped (tty input)");
146 #if defined (SIGTTOU)
147 init_sig (SIGTTOU
, "TTOU", "Stopped (tty output)");
149 #if defined (SIGSTOP)
150 init_sig (SIGSTOP
, "STOP", "Stopped (signal)");
152 #if defined (SIGXCPU)
153 init_sig (SIGXCPU
, "XCPU", "CPU time limit exceeded");
155 #if defined (SIGXFSZ)
156 init_sig (SIGXFSZ
, "XFSZ", "File size limit exceeded");
158 #if defined (SIGVTALRM)
159 init_sig (SIGVTALRM
, "VTALRM", "Virtual timer expired");
161 #if defined (SIGPROF)
162 init_sig (SIGPROF
, "PROF", "Profiling timer expired");
164 #if defined (SIGWINCH)
165 /* "Window size changed" might be more accurate, but even if that
166 is all that it means now, perhaps in the future it will be
167 extended to cover other kinds of window changes. */
168 init_sig (SIGWINCH
, "WINCH", "Window changed");
170 #if defined (SIGCONT)
171 init_sig (SIGCONT
, "CONT", "Continued");
174 init_sig (SIGURG
, "URG", "Urgent I/O condition");
177 /* "I/O pending" has also been suggested. A disadvantage is
178 that signal only happens when the process has
179 asked for it, not everytime I/O is pending. Another disadvantage
180 is the confusion from giving it a different name than under Unix. */
181 init_sig (SIGIO
, "IO", "I/O possible");
183 #if defined (SIGWIND)
184 init_sig (SIGWIND
, "WIND", "SIGWIND");
186 #if defined (SIGPHONE)
187 init_sig (SIGPHONE
, "PHONE", "SIGPHONE");
189 #if defined (SIGPOLL)
190 init_sig (SIGPOLL
, "POLL", "I/O possible");
192 #if defined (SIGLOST)
193 init_sig (SIGLOST
, "LOST", "Resource lost");
197 /* Return the abbreviation for signal NUMBER. */
204 for (i
= 0; i
< sig_table_nelts
; i
++)
205 if (sig_table
[i
].number
== number
)
206 return (char *)sig_table
[i
].abbrev
;
210 /* Return the signal number for an ABBREV, or -1 if there is no
211 signal by that name. */
218 /* Skip over "SIG" if present. */
219 if (abbrev
[0] == 'S' && abbrev
[1] == 'I' && abbrev
[2] == 'G')
222 for (i
= 0; i
< sig_table_nelts
; i
++)
223 if (abbrev
[0] == sig_table
[i
].abbrev
[0]
224 && strcmp (abbrev
, sig_table
[i
].abbrev
) == 0)
225 return sig_table
[i
].number
;
229 #if SYS_SIGLIST_MISSING
230 /* Print to standard error the name of SIGNAL, preceded by MESSAGE and
231 a colon, and followed by a newline. */
233 psignal (signal
, message
)
237 if (signal
<= 0 || signal
>= NSIG
)
238 fprintf (stderr
, "%s: unknown signal", message
);
240 fprintf (stderr
, "%s: %s\n", message
, sys_siglist
[signal
]);
242 #endif /* SYS_SIGLIST_MISSING */
245 _initialize_signame ()
This page took 0.045954 seconds and 5 git commands to generate.