diff src/siglist.c @ 5844:034cdbd34c0a

[project @ 2006-06-07 15:38:58 by jwe]
author jwe
date Wed, 07 Jun 2006 15:38:58 +0000
parents 4c8a2e4e0717
children 93c65f2a5668
line wrap: on
line diff
--- a/src/siglist.c
+++ b/src/siglist.c
@@ -29,118 +29,211 @@
 
 #include "siglist.h"
 
-#ifndef HAVE_SYS_SIGLIST
-char *sys_siglist[NSIG + 1] =
+/* The following is all borrowed from Emacs.  */
+
+#if ! (defined HAVE_STRSIGNAL || HAVE_DECL_SYS_SIGLIST)
+
+static char *my_sys_siglist[NSIG];
+
+#ifdef sys_siglist
+#undef sys_siglist
+#endif
+#define sys_siglist my_sys_siglist
+
+#endif
+
+void
+init_signals (void)
 {
-#ifdef AIX
-/* AIX has changed the signals a bit */
-  "bogus signal",			/* 0 */
-  "hangup",				/* 1  SIGHUP */
-  "interrupt",				/* 2  SIGINT */
-  "quit",				/* 3  SIGQUIT */
-  "illegal instruction",		/* 4  SIGILL */
-  "trace trap",				/* 5  SIGTRAP */
-  "IOT instruction",			/* 6  SIGIOT */
-  "crash likely",			/* 7  SIGDANGER */
-  "floating point exception",		/* 8  SIGFPE */
-  "kill",				/* 9  SIGKILL */
-  "bus error",				/* 10 SIGBUS */
-  "segmentation violation",		/* 11 SIGSEGV */
-  "bad argument to system call",	/* 12 SIGSYS */
-  "write on a pipe with no one to read it", /* 13 SIGPIPE */
-  "alarm clock",			/* 14 SIGALRM */
-  "software termination signum",	/* 15 SIGTERM */
-  "user defined signal 1",		/* 16 SIGUSR1 */
-  "user defined signal 2",		/* 17 SIGUSR2 */
-  "death of a child",			/* 18 SIGCLD */
-  "power-fail restart",			/* 19 SIGPWR */
-  "bogus signal",			/* 20 */
-  "bogus signal",			/* 21 */
-  "bogus signal",			/* 22 */
-  "bogus signal",			/* 23 */
-  "bogus signal",			/* 24 */
-  "LAN I/O interrupt",			/* 25 SIGAIO */
-  "PTY I/O interrupt",			/* 26 SIGPTY */
-  "I/O intervention required",		/* 27 SIGIOINT */
-  "HFT grant",				/* 28 SIGGRANT */
-  "HFT retract",			/* 29 SIGRETRACT */
-  "HFT sound done",			/* 30 SIGSOUND */
-  "HFT input ready",			/* 31 SIGMSG */
-#else /* not AIX */
-#ifdef __EMX__
-  "bogus signal #0",                    /* 0 */
-  "hangup",                             /* 1  SIGHUP */
-  "interrupt (Ctrl-C)",                 /* 2  SIGINT (Ctrl-C) */
-  "quit",                               /* 3  SIGQUIT */
-  "illegal instruction",                /* 4  SIGILL */
-  "single step",                        /* 5  SIGTRAP */
-  "abort",                              /* 6  SIGABRT */
-  "EMT instruction",                    /* 7  SIGEMT */
-  "floating point exception",           /* 8  SIGFPE */
-  "kill",                               /* 9  SIGKILL */
-  "bus error",                          /* 10 SIGBUS */
-  "segmentation violation",             /* 11 SIGSEGV */
-  "bad argument to system call",        /* 12 SIGSYS */
-  "broken pipe",                        /* 13 SIGPIPE */
-  "alarm clock",                        /* 14 SIGALRM */
-  "software termination signum",        /* 15 SIGTERM */
-  "user defined signal 1",              /* 16 SIGUSR1 */
-  "user defined signal 2",              /* 17 SIGUSR2 */
-  "death of a child",                   /* 18 SIGCHLD */
-  "bogus signal #20",                   /* 19 */
-  "bogus signal #21",                   /* 20 */
-  "break (Ctrl-Break)",                 /* 21 SIGBREAK */
-#else /* not __EMX__ */
-  "bogus signal",			/* 0 */
-  "hangup",				/* 1  SIGHUP */
-  "interrupt",				/* 2  SIGINT */
-  "quit",				/* 3  SIGQUIT */
-  "illegal instruction",		/* 4  SIGILL */
-  "trace trap",				/* 5  SIGTRAP */
-  "IOT instruction",			/* 6  SIGIOT */
-  "EMT instruction",			/* 7  SIGEMT */
-  "floating point exception",		/* 8  SIGFPE */
-  "kill",				/* 9  SIGKILL */
-  "bus error",				/* 10 SIGBUS */
-  "segmentation violation",		/* 11 SIGSEGV */
-  "bad argument to system call",	/* 12 SIGSYS */
-  "write on a pipe with no one to read it", /* 13 SIGPIPE */
-  "alarm clock",			/* 14 SIGALRM */
-  "software termination signum",	/* 15 SIGTERM */
-  "user defined signal 1",		/* 16 SIGUSR1 */
-  "user defined signal 2",		/* 17 SIGUSR2 */
-  "death of a child",			/* 18 SIGCLD */
-  "power-fail restart",			/* 19 SIGPWR */
-#ifdef sun
-  "window size change",			    /* 20 SIGWINCH */
-  "urgent socket condition",		    /* 21 SIGURG */
-  "pollable event occured",		    /* 22 SIGPOLL */
-  "stop (cannot be caught or ignored)", /*  23 SIGSTOP */
-  "user stop requested from tty",	    /* 24 SIGTSTP */
-  "stopped process has been continued",	/* 25 SIGCONT */
-  "background tty read attempted",	    /* 26 SIGTTIN */
-  "background tty write attempted",    /* 27 SIGTTOU */
-  "virtual timer expired",		    /* 28 SIGVTALRM */
-  "profiling timer expired",		    /* 29 SIGPROF */
-  "exceeded cpu limit",			    /* 30 SIGXCPU */
-  "exceeded file size limit",		    /* 31 SIGXFSZ */
-  "process's lwps are blocked",	    /*  32 SIGWAITING */
-  "special signal used by thread library", /* 33 SIGLWP */
-#ifdef SIGFREEZE
-  "Special Signal Used By CPR",	    /* 34 SIGFREEZE */
+#if ! (defined HAVE_STRSIGNAL || HAVE_DECL_SYS_SIGLIST)
+
+  static int initialized = 0;
+
+  if (! initialized)
+    {
+      initialized = 1;
+
+# ifdef SIGABRT
+      sys_siglist[SIGABRT] = "Aborted";
+# endif
+# ifdef SIGAIO
+      sys_siglist[SIGAIO] = "LAN I/O interrupt";
+# endif
+# ifdef SIGALRM
+      sys_siglist[SIGALRM] = "Alarm clock";
+# endif
+# ifdef SIGBUS
+      sys_siglist[SIGBUS] = "Bus error";
+# endif
+# ifdef SIGCLD
+      sys_siglist[SIGCLD] = "Child status changed";
+# endif
+# ifdef SIGCHLD
+      sys_siglist[SIGCHLD] = "Child status changed";
+# endif
+# ifdef SIGCONT
+      sys_siglist[SIGCONT] = "Continued";
+# endif
+# ifdef SIGDANGER
+      sys_siglist[SIGDANGER] = "Swap space dangerously low";
+# endif
+# ifdef SIGDGNOTIFY
+      sys_siglist[SIGDGNOTIFY] = "Notification message in queue";
+# endif
+# ifdef SIGEMT
+      sys_siglist[SIGEMT] = "Emulation trap";
+# endif
+# ifdef SIGFPE
+      sys_siglist[SIGFPE] = "Arithmetic exception";
+# endif
+# ifdef SIGFREEZE
+      sys_siglist[SIGFREEZE] = "SIGFREEZE";
+# endif
+# ifdef SIGGRANT
+      sys_siglist[SIGGRANT] = "Monitor mode granted";
+# endif
+# ifdef SIGHUP
+      sys_siglist[SIGHUP] = "Hangup";
+# endif
+# ifdef SIGILL
+      sys_siglist[SIGILL] = "Illegal instruction";
+# endif
+# ifdef SIGINT
+      sys_siglist[SIGINT] = "Interrupt";
+# endif
+# ifdef SIGIO
+      sys_siglist[SIGIO] = "I/O possible";
+# endif
+# ifdef SIGIOINT
+      sys_siglist[SIGIOINT] = "I/O intervention required";
+# endif
+# ifdef SIGIOT
+      sys_siglist[SIGIOT] = "IOT trap";
+# endif
+# ifdef SIGKILL
+      sys_siglist[SIGKILL] = "Killed";
+# endif
+# ifdef SIGLOST
+      sys_siglist[SIGLOST] = "Resource lost";
+# endif
+# ifdef SIGLWP
+      sys_siglist[SIGLWP] = "SIGLWP";
+# endif
+# ifdef SIGMSG
+      sys_siglist[SIGMSG] = "Monitor mode data available";
+# endif
+# ifdef SIGPHONE
+      sys_siglist[SIGWIND] = "SIGPHONE";
+# endif
+# ifdef SIGPIPE
+      sys_siglist[SIGPIPE] = "Broken pipe";
+# endif
+# ifdef SIGPOLL
+      sys_siglist[SIGPOLL] = "Pollable event occurred";
+# endif
+# ifdef SIGPROF
+      sys_siglist[SIGPROF] = "Profiling timer expired";
+# endif
+# ifdef SIGPTY
+      sys_siglist[SIGPTY] = "PTY I/O interrupt";
+# endif
+# ifdef SIGPWR
+      sys_siglist[SIGPWR] = "Power-fail restart";
+# endif
+# ifdef SIGQUIT
+      sys_siglist[SIGQUIT] = "Quit";
+# endif
+# ifdef SIGRETRACT
+      sys_siglist[SIGRETRACT] = "Need to relinguish monitor mode";
+# endif
+# ifdef SIGSAK
+      sys_siglist[SIGSAK] = "Secure attention";
+# endif
+# ifdef SIGSEGV
+      sys_siglist[SIGSEGV] = "Segmentation violation";
+# endif
+# ifdef SIGSOUND
+      sys_siglist[SIGSOUND] = "Sound completed";
+# endif
+# ifdef SIGSTOP
+      sys_siglist[SIGSTOP] = "Stopped (signal)";
+# endif
+# ifdef SIGSTP
+      sys_siglist[SIGSTP] = "Stopped (user)";
+# endif
+# ifdef SIGSYS
+      sys_siglist[SIGSYS] = "Bad argument to system call";
+# endif
+# ifdef SIGTERM
+      sys_siglist[SIGTERM] = "Terminated";
+# endif
+# ifdef SIGTHAW
+      sys_siglist[SIGTHAW] = "SIGTHAW";
+# endif
+# ifdef SIGTRAP
+      sys_siglist[SIGTRAP] = "Trace/breakpoint trap";
+# endif
+# ifdef SIGTSTP
+      sys_siglist[SIGTSTP] = "Stopped (user)";
+# endif
+# ifdef SIGTTIN
+      sys_siglist[SIGTTIN] = "Stopped (tty input)";
+# endif
+# ifdef SIGTTOU
+      sys_siglist[SIGTTOU] = "Stopped (tty output)";
+# endif
+# ifdef SIGURG
+      sys_siglist[SIGURG] = "Urgent I/O condition";
+# endif
+# ifdef SIGUSR1
+      sys_siglist[SIGUSR1] = "User defined signal 1";
+# endif
+# ifdef SIGUSR2
+      sys_siglist[SIGUSR2] = "User defined signal 2";
+# endif
+# ifdef SIGVTALRM
+      sys_siglist[SIGVTALRM] = "Virtual timer expired";
+# endif
+# ifdef SIGWAITING
+      sys_siglist[SIGWAITING] = "Process's LWPs are blocked";
+# endif
+# ifdef SIGWINCH
+      sys_siglist[SIGWINCH] = "Window size changed";
+# endif
+# ifdef SIGWIND
+      sys_siglist[SIGWIND] = "SIGWIND";
+# endif
+# ifdef SIGXCPU
+      sys_siglist[SIGXCPU] = "CPU time limit exceeded";
+# endif
+# ifdef SIGXFSZ
+      sys_siglist[SIGXFSZ] = "File size limit exceeded";
+# endif
+    }
+
 #endif
-#ifdef SIGTHAW
-  "Special Signal Used By CPR",	    /* 35 SIGTHAW */
-#endif
-#endif /* sun */
-#endif /* __EMX__ */
-#endif /* AIX */
-  0
-  };
+}
+
+#if ! defined (HAVE_STRSIGNAL)
+
+char *
+strsignal (int code)
+{
+  char *signame = "";
+
+  if (0 <= code && code < NSIG)
+    {
+      /* Cast to suppress warning if the table has const char *.  */
+      signame = (char *) sys_siglist[code];
+    }
+
+  return signame;
+}
+
 #endif
 
 /*
 ;;; Local Variables: ***
-;;; mode: C++ ***
+;;; mode: C ***
 ;;; End: ***
 */