1993-07-26 20:20:42 +00:00
|
|
|
/* Convert between signal names and numbers.
|
2002-04-21 23:57:24 +00:00
|
|
|
Copyright (C) 1990,92,93,95,96,99, 2002 Free Software Foundation, Inc.
|
|
|
|
This file was part of the GNU C Library, but is now part of GNU make.
|
1997-06-23 22:48:40 +00:00
|
|
|
|
2002-04-21 23:57:24 +00:00
|
|
|
GNU Make is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
any later version.
|
1997-06-23 22:48:40 +00:00
|
|
|
|
2002-04-21 23:57:24 +00:00
|
|
|
GNU Make is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
1997-06-23 22:48:40 +00:00
|
|
|
|
2002-04-21 23:57:24 +00:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with GNU Make; see the file COPYING. If not, write to
|
|
|
|
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
Boston, MA 02111-1307, USA. */
|
1993-07-26 20:20:42 +00:00
|
|
|
|
1999-11-17 07:33:47 +00:00
|
|
|
#include "make.h"
|
1995-04-26 21:19:26 +00:00
|
|
|
|
2002-04-21 23:57:24 +00:00
|
|
|
/* If the system provides strsignal, we don't need it. */
|
|
|
|
|
|
|
|
#if !defined(HAVE_STRSIGNAL)
|
|
|
|
|
|
|
|
/* If the system provides sys_siglist, we'll use that.
|
|
|
|
Otherwise create our own.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if !defined(SYS_SIGLIST_DECLARED)
|
1995-04-26 21:19:26 +00:00
|
|
|
|
1993-07-26 20:20:42 +00:00
|
|
|
/* Some systems do not define NSIG in <signal.h>. */
|
|
|
|
#ifndef NSIG
|
|
|
|
#ifdef _NSIG
|
|
|
|
#define NSIG _NSIG
|
|
|
|
#else
|
|
|
|
#define NSIG 32
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* There is too much variation in Sys V signal numbers and names, so
|
|
|
|
we must initialize them at runtime. */
|
|
|
|
|
1999-07-28 06:23:37 +00:00
|
|
|
static const char *undoc;
|
1993-07-26 20:20:42 +00:00
|
|
|
|
2002-04-21 23:57:24 +00:00
|
|
|
static const char *sys_siglist[NSIG];
|
1993-07-26 20:20:42 +00:00
|
|
|
|
|
|
|
/* Table of abbreviations for signals. Note: A given number can
|
|
|
|
appear more than once with different abbreviations. */
|
1999-02-19 18:07:49 +00:00
|
|
|
#define SIG_TABLE_SIZE (NSIG*2)
|
|
|
|
|
1993-07-26 20:20:42 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int number;
|
|
|
|
const char *abbrev;
|
|
|
|
} num_abbrev;
|
2002-04-21 23:57:24 +00:00
|
|
|
|
1999-02-19 18:07:49 +00:00
|
|
|
static num_abbrev sig_table[SIG_TABLE_SIZE];
|
2002-04-21 23:57:24 +00:00
|
|
|
|
1993-07-26 20:20:42 +00:00
|
|
|
/* Number of elements of sig_table used. */
|
|
|
|
static int sig_table_nelts = 0;
|
|
|
|
|
|
|
|
/* Enter signal number NUMBER into the tables with ABBREV and NAME. */
|
|
|
|
|
|
|
|
static void
|
2002-10-14 21:54:04 +00:00
|
|
|
init_sig (int number, const char *abbrev, const char *name)
|
1993-07-26 20:20:42 +00:00
|
|
|
{
|
1999-02-19 18:07:49 +00:00
|
|
|
/* If this value is ever greater than NSIG it seems like it'd be a bug in
|
|
|
|
the system headers, but... better safe than sorry. We know, for
|
|
|
|
example, that this isn't always true on VMS. */
|
|
|
|
|
|
|
|
if (number >= 0 && number < NSIG)
|
|
|
|
sys_siglist[number] = name;
|
2002-04-21 23:57:24 +00:00
|
|
|
|
1999-02-19 18:07:49 +00:00
|
|
|
if (sig_table_nelts < SIG_TABLE_SIZE)
|
|
|
|
{
|
|
|
|
sig_table[sig_table_nelts].number = number;
|
|
|
|
sig_table[sig_table_nelts++].abbrev = abbrev;
|
|
|
|
}
|
1993-07-26 20:20:42 +00:00
|
|
|
}
|
|
|
|
|
2002-04-21 23:57:24 +00:00
|
|
|
static int
|
2002-10-14 21:54:04 +00:00
|
|
|
signame_init (void)
|
1993-07-26 20:20:42 +00:00
|
|
|
{
|
|
|
|
int i;
|
1999-07-28 06:23:37 +00:00
|
|
|
|
2002-09-18 04:35:52 +00:00
|
|
|
undoc = xstrdup (_("unknown signal"));
|
1999-07-28 06:23:37 +00:00
|
|
|
|
1993-07-26 20:20:42 +00:00
|
|
|
/* Initialize signal names. */
|
|
|
|
for (i = 0; i < NSIG; i++)
|
|
|
|
sys_siglist[i] = undoc;
|
|
|
|
|
|
|
|
/* Initialize signal names. */
|
|
|
|
#if defined (SIGHUP)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGHUP, "HUP", _("Hangup"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
|
|
|
#if defined (SIGINT)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGINT, "INT", _("Interrupt"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
|
|
|
#if defined (SIGQUIT)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGQUIT, "QUIT", _("Quit"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
|
|
|
#if defined (SIGILL)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGILL, "ILL", _("Illegal Instruction"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
|
|
|
#if defined (SIGTRAP)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGTRAP, "TRAP", _("Trace/breakpoint trap"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
|
|
|
/* If SIGIOT == SIGABRT, we want to print it as SIGABRT because
|
|
|
|
SIGABRT is in ANSI and POSIX.1 and SIGIOT isn't. */
|
|
|
|
#if defined (SIGABRT)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGABRT, "ABRT", _("Aborted"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
|
|
|
#if defined (SIGIOT)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGIOT, "IOT", _("IOT trap"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
|
|
|
#if defined (SIGEMT)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGEMT, "EMT", _("EMT trap"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
|
|
|
#if defined (SIGFPE)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGFPE, "FPE", _("Floating point exception"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
|
|
|
#if defined (SIGKILL)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGKILL, "KILL", _("Killed"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
|
|
|
#if defined (SIGBUS)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGBUS, "BUS", _("Bus error"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
|
|
|
#if defined (SIGSEGV)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGSEGV, "SEGV", _("Segmentation fault"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
|
|
|
#if defined (SIGSYS)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGSYS, "SYS", _("Bad system call"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
|
|
|
#if defined (SIGPIPE)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGPIPE, "PIPE", _("Broken pipe"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
|
|
|
#if defined (SIGALRM)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGALRM, "ALRM", _("Alarm clock"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
|
|
|
#if defined (SIGTERM)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGTERM, "TERM", _("Terminated"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
|
|
|
#if defined (SIGUSR1)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGUSR1, "USR1", _("User defined signal 1"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
|
|
|
#if defined (SIGUSR2)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGUSR2, "USR2", _("User defined signal 2"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
|
|
|
/* If SIGCLD == SIGCHLD, we want to print it as SIGCHLD because that
|
|
|
|
is what is in POSIX.1. */
|
|
|
|
#if defined (SIGCHLD)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGCHLD, "CHLD", _("Child exited"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
|
|
|
#if defined (SIGCLD)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGCLD, "CLD", _("Child exited"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
|
|
|
#if defined (SIGPWR)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGPWR, "PWR", _("Power failure"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
|
|
|
#if defined (SIGTSTP)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGTSTP, "TSTP", _("Stopped"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
|
|
|
#if defined (SIGTTIN)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGTTIN, "TTIN", _("Stopped (tty input)"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
|
|
|
#if defined (SIGTTOU)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGTTOU, "TTOU", _("Stopped (tty output)"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
|
|
|
#if defined (SIGSTOP)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGSTOP, "STOP", _("Stopped (signal)"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
|
|
|
#if defined (SIGXCPU)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGXCPU, "XCPU", _("CPU time limit exceeded"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
|
|
|
#if defined (SIGXFSZ)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGXFSZ, "XFSZ", _("File size limit exceeded"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
|
|
|
#if defined (SIGVTALRM)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGVTALRM, "VTALRM", _("Virtual timer expired"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
|
|
|
#if defined (SIGPROF)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGPROF, "PROF", _("Profiling timer expired"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
|
|
|
#if defined (SIGWINCH)
|
|
|
|
/* "Window size changed" might be more accurate, but even if that
|
|
|
|
is all that it means now, perhaps in the future it will be
|
|
|
|
extended to cover other kinds of window changes. */
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGWINCH, "WINCH", _("Window changed"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
|
|
|
#if defined (SIGCONT)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGCONT, "CONT", _("Continued"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
|
|
|
#if defined (SIGURG)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGURG, "URG", _("Urgent I/O condition"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
|
|
|
#if defined (SIGIO)
|
|
|
|
/* "I/O pending" has also been suggested. A disadvantage is
|
|
|
|
that signal only happens when the process has
|
|
|
|
asked for it, not everytime I/O is pending. Another disadvantage
|
|
|
|
is the confusion from giving it a different name than under Unix. */
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGIO, "IO", _("I/O possible"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
|
|
|
#if defined (SIGWIND)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGWIND, "WIND", _("SIGWIND"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
|
|
|
#if defined (SIGPHONE)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGPHONE, "PHONE", _("SIGPHONE"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
|
|
|
#if defined (SIGPOLL)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGPOLL, "POLL", _("I/O possible"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
|
|
|
#if defined (SIGLOST)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGLOST, "LOST", _("Resource lost"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
|
|
|
#if defined (SIGDANGER)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGDANGER, "DANGER", _("Danger signal"));
|
1993-07-26 20:20:42 +00:00
|
|
|
#endif
|
1995-03-21 21:44:32 +00:00
|
|
|
#if defined (SIGINFO)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGINFO, "INFO", _("Information request"));
|
1995-03-21 21:44:32 +00:00
|
|
|
#endif
|
1997-04-07 07:21:16 +00:00
|
|
|
#if defined (SIGNOFP)
|
1999-07-28 06:23:37 +00:00
|
|
|
init_sig (SIGNOFP, "NOFP", _("Floating point co-processor not available"));
|
1997-04-07 07:21:16 +00:00
|
|
|
#endif
|
1993-07-26 20:20:42 +00:00
|
|
|
|
2002-04-21 23:57:24 +00:00
|
|
|
return 1;
|
1993-07-26 20:20:42 +00:00
|
|
|
}
|
|
|
|
|
2002-04-21 23:57:24 +00:00
|
|
|
#endif /* SYS_SIGLIST_DECLARED */
|
1993-07-26 20:20:42 +00:00
|
|
|
|
1995-02-22 03:13:12 +00:00
|
|
|
|
|
|
|
char *
|
2002-10-14 21:54:04 +00:00
|
|
|
strsignal (int signal)
|
1995-02-22 03:13:12 +00:00
|
|
|
{
|
|
|
|
static char buf[] = "Signal 12345678901234567890";
|
1996-03-20 14:59:27 +00:00
|
|
|
|
2002-04-21 23:57:24 +00:00
|
|
|
#if !defined(SYS_SIGLIST_DECLARED)
|
|
|
|
static char sig_initted = 0;
|
|
|
|
|
|
|
|
if (!sig_initted)
|
|
|
|
sig_initted = signame_init ();
|
|
|
|
#endif
|
|
|
|
|
1995-02-22 03:13:12 +00:00
|
|
|
if (signal > 0 || signal < NSIG)
|
1995-03-07 06:41:05 +00:00
|
|
|
return (char *) sys_siglist[signal];
|
1996-03-20 14:59:27 +00:00
|
|
|
|
1995-02-22 03:13:12 +00:00
|
|
|
sprintf (buf, "Signal %d", signal);
|
|
|
|
return buf;
|
|
|
|
}
|
2002-04-21 23:57:24 +00:00
|
|
|
|
|
|
|
#endif /* HAVE_STRSIGNAL */
|