]> granicus.if.org Git - sudo/commitdiff
Build our own sys_siglist for systems that lack it.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 4 Jun 2010 20:06:24 +0000 (16:06 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 4 Jun 2010 20:06:24 +0000 (16:06 -0400)
--HG--
branch : 1.7

Makefile.in
config.h.in
configure
configure.in
missing.h
mksiglist.c [new file with mode: 0644]
mksiglist.h [new file with mode: 0644]
siglist.in [new file with mode: 0644]
strsignal.c

index 21d386700a4d9f42cde5a06e26956701856e6d6e..6143ff6afc3162fa2d6d3a4b3b1af48af216dea3 100644 (file)
@@ -106,12 +106,12 @@ SRCS = aix.c alias.c alloc.c audit.c boottime.c bsm_audit.c check.c \
        closefrom.c def_data.c defaults.c env.c error.c exec.c fileops.c \
        find_path.c fnmatch.c getcwd.c getprogname.c getspwuid.c gettime.c \
        glob.c goodpath.c gram.c gram.y interfaces.c iolog.c isblank.c lbuf.c \
-       ldap.c list.c logging.c match.c mkstemp.c memrchr.c nanosleep.c \
-       parse.c pwutil.c pty.c set_perms.c sigaction.c snprintf.c strcasecmp.c \
-       strerror.c strlcat.c strlcpy.c strsignal.c sudo.c sudo_noexec.c \
-       sudo_edit.c sudo_nss.c term.c testsudoers.c tgetpass.c toke.c toke.l \
-       tsgetgrpw.c utimes.c vasgroups.c visudo.c zero_bytes.c redblack.c \
-       selinux.c sesh.c sudoreplay.c getdate.c getdate.y getline.c \
+       ldap.c list.c logging.c match.c mksiglist.c mkstemp.c memrchr.c \
+       nanosleep.c parse.c pwutil.c pty.c set_perms.c sigaction.c snprintf.c \
+       strcasecmp.c strerror.c strlcat.c strlcpy.c strsignal.c sudo.c \
+       sudo_noexec.c sudo_edit.c sudo_nss.c term.c testsudoers.c tgetpass.c \
+       toke.c toke.l tsgetgrpw.c utimes.c vasgroups.c visudo.c zero_bytes.c \
+       redblack.c selinux.c sesh.c sudoreplay.c getdate.c getdate.y getline.c \
        timestr.c $(AUTH_SRCS)
 
 AUTH_SRCS = auth/afs.c auth/aix_auth.c auth/bsdauth.c auth/dce.c auth/fwtk.c \
@@ -121,9 +121,9 @@ AUTH_SRCS = auth/afs.c auth/aix_auth.c auth/bsdauth.c auth/dce.c auth/fwtk.c \
 
 HDRS = alloc.h bsm_audit.h compat.h def_data.h defaults.h error.h ins_2001.h \
        ins_classic.h ins_csops.h ins_goons.h insults.h interfaces.h lbuf.h \
-       list.h logging.h missing.h nonunix.h redblack.h parse.h sudo.h \
-       sudo_nss.h gram.h auth/sudo_auth.h emul/charclass.h emul/fnmatch.h \
-       emul/glob.h emul/timespec.h emul/utime.h
+       list.h logging.h missing.h mksiglist.h nonunix.h redblack.h parse.h \
+       sudo.h sudo_nss.h gram.h auth/sudo_auth.h emul/charclass.h \
+       emul/fnmatch.h emul/glob.h emul/timespec.h emul/utime.h
 
 AUTH_OBJS = sudo_auth.o @AUTH_OBJS@
 
@@ -148,16 +148,17 @@ VERSION = @PACKAGE_VERSION@
 
 DISTFILES = $(SRCS) $(HDRS) ChangeLog HISTORY INSTALL INSTALL.configure \
             LICENSE Makefile.in PORTING README README.LDAP TROUBLESHOOTING \
-           UPGRADE WHATSNEW aclocal.m4 acsite.m4 aixcrypt.exp config.guess \
-           config.h.in config.sub configure configure.in def_data.in \
-           indent.pro install-sh ltmain.sh mkdefaults mkinstalldirs \
-           pathnames.h.in sample.pam sample.syslog.conf sample.sudoers \
-           schema.ActiveDirectory schema.OpenLDAP schema.iPlanet sudo.cat \
-           sudo.man.in sudo.pod sudo.psf sudo_usage.h.in sudoers sudoers.cat \
-            sudoers.man.in sudoers.pod sudoers.ldap.cat sudoers.ldap.man.in \
-           sudoers.ldap.pod sudoers2ldif sudoreplay.cat sudoreplay.man.in \
-           sudoreplay.pod visudo.cat visudo.man.in visudo.pod auth/API \
-           sudo.man.pl sudoers.man.pl
+            UPGRADE WHATSNEW aclocal.m4 acsite.m4 aixcrypt.exp config.guess \
+            config.h.in config.sub configure configure.in def_data.in \
+            indent.pro install-sh ltmain.sh mkdefaults mkinstalldirs \
+            mksiglist.in pathnames.h.in sample.pam sample.syslog.conf \
+            sample.sudoers schema.ActiveDirectory schema.OpenLDAP \
+            schema.iPlanet sudo.cat sudo.man.in sudo.pod sudo.psf \
+            sudo_usage.h.in sudoers sudoers.cat sudoers.man.in sudoers.pod \
+            sudoers.ldap.cat sudoers.ldap.man.in sudoers.ldap.pod \
+            sudoers2ldif sudoreplay.cat sudoreplay.man.in sudoreplay.pod \
+            visudo.cat visudo.man.in visudo.pod auth/API sudo.man.pl \
+            sudoers.man.pl
 
 BINFILES= ChangeLog HISTORY LICENSE README TROUBLESHOOTING \
          UPGRADE install-sh mkinstalldirs sample.syslog.conf sample.sudoers \
@@ -240,6 +241,15 @@ $(devdir)/getdate.c: $(srcdir)/getdate.y
 @DEV@$(devdir)/def_data.h $(devdir)/def_data.c: $(srcdir)/def_data.in
 @DEV@  perl $(srcdir)/mkdefaults -o def_data $(srcdir)/def_data.in
 
+siglist.c: mksiglist
+       ./mksiglist > $@
+
+mksiglist: $(srcdir)/mksiglist.c $(srcdir)/mksiglist.h $(srcdir)/compat.h $(top_builddir)/config.h
+       $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFS) $(srcdir)/mksiglist.c -o $@
+
+@DEV@$(srcdir)/mksiglist.h: $(srcdir)/siglist.in
+@DEV@  awk 'BEGIN {print "/* public domain */\n"} /^    [A-Z]/ {printf("#ifdef SIG%s\n    if (my_sys_siglist[SIG%s] == NULL)\n\tmy_sys_siglist[SIG%s] = \"%s\";\n#endif\n", $$1, $$1, $$1, substr($$0, 13))}' < $(srcdir)/siglist.in > $@
+
 # Dependencies (not counting auth functions)
 aix.o: $(srcdir)/aix.c
        $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/aix.c
@@ -323,6 +333,8 @@ set_perms.o: $(srcdir)/set_perms.c $(SUDODEP)
        $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/set_perms.c
 sigaction.o: $(srcdir)/sigaction.c $(srcdir)/compat.h
        $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/sigaction.c
+siglist.o: siglist.c $(srcdir)/compat.h config.h
+       $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/siglist.c
 snprintf.o: $(srcdir)/snprintf.c $(srcdir)/compat.h config.h
        $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/snprintf.c
 strcasecmp.o: $(srcdir)/strcasecmp.c $(srcdir)/compat.h  config.h
index d6a011a236f98a22160e15303517e8dfd1d6caad..4ebc7c5ed2acbd4bdbc57109c0ec175bc4e461f2 100644 (file)
 /* Define to 1 if your `DIR' contains dd_fd. */
 #undef HAVE_DD_FD
 
+/* Define to 1 if you have the declaration of `sys_siglist', and to 0 if you
+   don't. */
+#undef HAVE_DECL_SYS_SIGLIST
+
+/* Define to 1 if you have the declaration of `_sys_siglist', and to 0 if you
+   don't. */
+#undef HAVE_DECL__SYS_SIGLIST
+
+/* Define to 1 if you have the declaration of `__sys_siglist', and to 0 if you
+   don't. */
+#undef HAVE_DECL___SYS_SIGLIST
+
 /* Define to 1 if you have the `dgettext' function. */
 #undef HAVE_DGETTEXT
 
 /* Define to 1 if you have the <sys/select.h> header file. */
 #undef HAVE_SYS_SELECT_H
 
-/* Define to 1 if you have the 'sys_siglist' symbol in libc. */
-#undef HAVE_SYS_SIGLIST
-
 /* Define to 1 if you have the <sys/sockio.h> header file. */
 #undef HAVE_SYS_SOCKIO_H
 
index 9d6880b58880878c6e3e9e10ee9e089ebad3b195..9d871a63ce6a6d55970e8212165e6c14a120f38f 100755 (executable)
--- a/configure
+++ b/configure
@@ -15841,46 +15841,82 @@ _ACEOF
 
 else
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sys_siglist" >&5
-$as_echo_n "checking for sys_siglist... " >&6; }
-    if test "${sudo_cv_sys_siglist+set}" = set; then :
-  $as_echo_n "(cached) " >&6
+    case " $LIBOBJS " in
+  *" strsignal.$ac_objext "* ) ;;
+  *) LIBOBJS="$LIBOBJS strsignal.$ac_objext"
+ ;;
+esac
+
+    HAVE_SIGLIST="false"
+    ac_fn_c_check_decl "$LINENO" "sys_siglist" "ac_cv_have_decl_sys_siglist" "
+$ac_includes_default
+#include <signal.h>
+
+"
+if test "x$ac_cv_have_decl_sys_siglist" = x""yes; then :
+  ac_have_decl=1
 else
+  ac_have_decl=0
+fi
 
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_SYS_SIGLIST $ac_have_decl
+_ACEOF
+if test $ac_have_decl = 1; then :
 
-int
-main ()
-{
-extern char *sys_siglist; char *hup = sys_siglist[1];
-  ;
-  return 0;
-}
+       HAVE_SIGLIST="true"
+       break
+
+fi
+ac_fn_c_check_decl "$LINENO" "_sys_siglist" "ac_cv_have_decl__sys_siglist" "
+$ac_includes_default
+#include <signal.h>
+
+"
+if test "x$ac_cv_have_decl__sys_siglist" = x""yes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL__SYS_SIGLIST $ac_have_decl
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  sudo_cv_sys_siglist=yes
+if test $ac_have_decl = 1; then :
+
+       HAVE_SIGLIST="true"
+       break
+
+fi
+ac_fn_c_check_decl "$LINENO" "__sys_siglist" "ac_cv_have_decl___sys_siglist" "
+$ac_includes_default
+#include <signal.h>
+
+"
+if test "x$ac_cv_have_decl___sys_siglist" = x""yes; then :
+  ac_have_decl=1
 else
-  sudo_cv_sys_siglist=no
+  ac_have_decl=0
 fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL___SYS_SIGLIST $ac_have_decl
+_ACEOF
+if test $ac_have_decl = 1; then :
+
+       HAVE_SIGLIST="true"
+       break
+
 fi
 
-    if test "$sudo_cv_sys_siglist" = "yes"; then
+    if test "$HAVE_SIGLIST" != "true"; then
        case " $LIBOBJS " in
-  *" strsignal.$ac_objext "* ) ;;
-  *) LIBOBJS="$LIBOBJS strsignal.$ac_objext"
+  *" siglist.$ac_objext "* ) ;;
+  *) LIBOBJS="$LIBOBJS siglist.$ac_objext"
  ;;
 esac
 
-       $as_echo "#define HAVE_SYS_SIGLIST 1" >>confdefs.h
-
-       $as_echo "#define HAVE_STRSIGNAL 1" >>confdefs.h
-
     fi
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $sudo_cv_sys_siglist" >&5
-$as_echo "$sudo_cv_sys_siglist" >&6; }
 
 fi
 done
@@ -20367,6 +20403,5 @@ fi
 
 
 
-
 
 
index 82151ea72855228219a3e4090f57b0e835c9e128..29d6490246c28bb0410fcec733ad728e1ecdac0a 100644 (file)
@@ -2001,15 +2001,18 @@ dnl
 dnl Check for strsignal() or sys_siglist
 dnl
 AC_CHECK_FUNCS(strsignal, [], [
-    AC_MSG_CHECKING([for sys_siglist])
-    AC_CACHE_VAL(sudo_cv_sys_siglist, [
-    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[extern char *sys_siglist; char *hup = sys_siglist[1];]])], [sudo_cv_sys_siglist=yes], [sudo_cv_sys_siglist=no])])
-    if test "$sudo_cv_sys_siglist" = "yes"; then
-       AC_LIBOBJ(strsignal)
-       AC_DEFINE(HAVE_SYS_SIGLIST)
-       AC_DEFINE(HAVE_STRSIGNAL)
+    AC_LIBOBJ(strsignal)
+    HAVE_SIGLIST="false"
+    AC_CHECK_DECLS([sys_siglist, _sys_siglist, __sys_siglist], [
+       HAVE_SIGLIST="true"
+       break
+    ], [ ], [
+AC_INCLUDES_DEFAULT
+#include <signal.h>
+    ])
+    if test "$HAVE_SIGLIST" != "true"; then
+       AC_LIBOBJ(siglist)
     fi
-    AC_MSG_RESULT($sudo_cv_sys_siglist)
 ])
 
 dnl
@@ -2807,7 +2810,6 @@ AH_TEMPLATE(HAVE_SKEYACCESS, [Define to 1 if your S/Key library has skeyaccess()
 AH_TEMPLATE(HAVE_ST__TIM, [Define to 1 if your struct stat uses an st__tim union])
 AH_TEMPLATE(HAVE_ST_MTIM, [Define to 1 if your struct stat has an st_mtim member])
 AH_TEMPLATE(HAVE_ST_MTIMESPEC, [Define to 1 if your struct stat has an st_mtimespec member])
-AH_TEMPLATE(HAVE_SYS_SIGLIST, [Define to 1 if you have the 'sys_siglist' symbol in libc.])
 AH_TEMPLATE(HAVE_TERMIOS_H, [Define to 1 if you have the <termios.h> header file and the `tcgetattr' function.])
 AH_TEMPLATE(HAVE_TIMESPEC, [Define to 1 if you have struct timespec in sys/time.h])
 AH_TEMPLATE(HAVE_TIMERSUB2, [Define to 1 if you have a timersub macro or function that takes two arguments (not three)])
index bb44e8a7784edc64c708dbec3ac2b6be030c20fc..b945eca01ea9467c41858fd8dc5b45522999f1f6 100644 (file)
--- a/missing.h
+++ b/missing.h
@@ -83,7 +83,7 @@ int setenv            __P((const char *, const char *, int));
 #ifndef HAVE_UNSETENV
 int unsetenv           __P((const char *));
 #endif
-#ifdef HAVE_SYS_SIGLIST
+#ifndef HAVE_STRSIGNAL
 char *strsignal                __P((int));
 #endif
 
diff --git a/mksiglist.c b/mksiglist.c
new file mode 100644 (file)
index 0000000..e703aff
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2010 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+
+#include <config.h>
+
+#include <stdio.h>
+#ifdef STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# ifdef HAVE_STDLIB_H
+#  include <stdlib.h>
+# endif
+#endif /* STDC_HEADERS */
+#include <signal.h>
+
+#include <compat.h>
+
+#if !defined(NSIG)
+# if defined(_NSIG)
+#  define NSIG _NSIG
+# elif defined(__NSIG)
+#  define NSIG __NSIG
+# else
+#  error one of NSIG, _NSIG, or __NSIG must be defined
+# endif
+#endif
+
+int
+main(argc, argv)
+    int argc;
+    char *argv[];
+{
+    static char *my_sys_siglist[NSIG];
+    int i;
+
+#include "mksiglist.h"
+
+    printf("#include <config.h>\n");
+    printf("#include <signal.h>\n");
+    printf("#include <compat.h>\n\n");
+    printf("const char *const my_sys_siglist[NSIG] = {\n");
+    for (i = 0; i < NSIG; i++) {
+       if (my_sys_siglist[i] != NULL) {
+           printf("    \"%s\",\n", my_sys_siglist[i]);
+       } else {
+           printf("    \"Signal %d\",\n", i);
+       }
+    }
+    printf("};\n");
+
+    exit(0);
+}
diff --git a/mksiglist.h b/mksiglist.h
new file mode 100644 (file)
index 0000000..f9f3294
--- /dev/null
@@ -0,0 +1,174 @@
+/* public domain */
+
+#ifdef SIGHUP
+    if (my_sys_siglist[SIGHUP] == NULL)
+       my_sys_siglist[SIGHUP] = "Hangup";
+#endif
+#ifdef SIGINT
+    if (my_sys_siglist[SIGINT] == NULL)
+       my_sys_siglist[SIGINT] = "Interrupt";
+#endif
+#ifdef SIGQUIT
+    if (my_sys_siglist[SIGQUIT] == NULL)
+       my_sys_siglist[SIGQUIT] = "Quit";
+#endif
+#ifdef SIGILL
+    if (my_sys_siglist[SIGILL] == NULL)
+       my_sys_siglist[SIGILL] = "Illegal instruction";
+#endif
+#ifdef SIGTRAP
+    if (my_sys_siglist[SIGTRAP] == NULL)
+       my_sys_siglist[SIGTRAP] = "Trace trap";
+#endif
+#ifdef SIGABRT
+    if (my_sys_siglist[SIGABRT] == NULL)
+       my_sys_siglist[SIGABRT] = "Abort";
+#endif
+#ifdef SIGIOT
+    if (my_sys_siglist[SIGIOT] == NULL)
+       my_sys_siglist[SIGIOT] = "IOT instruction";
+#endif
+#ifdef SIGEMT
+    if (my_sys_siglist[SIGEMT] == NULL)
+       my_sys_siglist[SIGEMT] = "EMT trap";
+#endif
+#ifdef SIGFPE
+    if (my_sys_siglist[SIGFPE] == NULL)
+       my_sys_siglist[SIGFPE] = "Floating point exception";
+#endif
+#ifdef SIGKILL
+    if (my_sys_siglist[SIGKILL] == NULL)
+       my_sys_siglist[SIGKILL] = "Killed";
+#endif
+#ifdef SIGUNUSED
+    if (my_sys_siglist[SIGUNUSED] == NULL)
+       my_sys_siglist[SIGUNUSED] = "Unused";
+#endif
+#ifdef SIGBUS
+    if (my_sys_siglist[SIGBUS] == NULL)
+       my_sys_siglist[SIGBUS] = "Bus error";
+#endif
+#ifdef SIGSEGV
+    if (my_sys_siglist[SIGSEGV] == NULL)
+       my_sys_siglist[SIGSEGV] = "Memory fault";
+#endif
+#ifdef SIGSYS
+    if (my_sys_siglist[SIGSYS] == NULL)
+       my_sys_siglist[SIGSYS] = "Bad system call";
+#endif
+#ifdef SIGPIPE
+    if (my_sys_siglist[SIGPIPE] == NULL)
+       my_sys_siglist[SIGPIPE] = "Broken pipe";
+#endif
+#ifdef SIGALRM
+    if (my_sys_siglist[SIGALRM] == NULL)
+       my_sys_siglist[SIGALRM] = "Alarm clock";
+#endif
+#ifdef SIGTERM
+    if (my_sys_siglist[SIGTERM] == NULL)
+       my_sys_siglist[SIGTERM] = "Terminated";
+#endif
+#ifdef SIGSTKFLT
+    if (my_sys_siglist[SIGSTKFLT] == NULL)
+       my_sys_siglist[SIGSTKFLT] = "Stack fault";
+#endif
+#ifdef SIGIO
+    if (my_sys_siglist[SIGIO] == NULL)
+       my_sys_siglist[SIGIO] = "I/O possible";
+#endif
+#ifdef SIGXCPU
+    if (my_sys_siglist[SIGXCPU] == NULL)
+       my_sys_siglist[SIGXCPU] = "CPU time limit exceeded";
+#endif
+#ifdef SIGXFSZ
+    if (my_sys_siglist[SIGXFSZ] == NULL)
+       my_sys_siglist[SIGXFSZ] = "File size limit exceeded";
+#endif
+#ifdef SIGVTALRM
+    if (my_sys_siglist[SIGVTALRM] == NULL)
+       my_sys_siglist[SIGVTALRM] = "Virtual timer expired";
+#endif
+#ifdef SIGPROF
+    if (my_sys_siglist[SIGPROF] == NULL)
+       my_sys_siglist[SIGPROF] = "Profiling timer expired";
+#endif
+#ifdef SIGWINCH
+    if (my_sys_siglist[SIGWINCH] == NULL)
+       my_sys_siglist[SIGWINCH] = "Window size change";
+#endif
+#ifdef SIGLOST
+    if (my_sys_siglist[SIGLOST] == NULL)
+       my_sys_siglist[SIGLOST] = "File lock lost";
+#endif
+#ifdef SIGUSR1
+    if (my_sys_siglist[SIGUSR1] == NULL)
+       my_sys_siglist[SIGUSR1] = "User defined signal 1";
+#endif
+#ifdef SIGUSR2
+    if (my_sys_siglist[SIGUSR2] == NULL)
+       my_sys_siglist[SIGUSR2] = "User defined signal 2";
+#endif
+#ifdef SIGPWR
+    if (my_sys_siglist[SIGPWR] == NULL)
+       my_sys_siglist[SIGPWR] = "Power-fail/Restart";
+#endif
+#ifdef SIGPOLL
+    if (my_sys_siglist[SIGPOLL] == NULL)
+       my_sys_siglist[SIGPOLL] = "Pollable event occurred";
+#endif
+#ifdef SIGSTOP
+    if (my_sys_siglist[SIGSTOP] == NULL)
+       my_sys_siglist[SIGSTOP] = "Stopped (signal)";
+#endif
+#ifdef SIGTSTP
+    if (my_sys_siglist[SIGTSTP] == NULL)
+       my_sys_siglist[SIGTSTP] = "Stopped";
+#endif
+#ifdef SIGCONT
+    if (my_sys_siglist[SIGCONT] == NULL)
+       my_sys_siglist[SIGCONT] = "Continued";
+#endif
+#ifdef SIGCHLD
+    if (my_sys_siglist[SIGCHLD] == NULL)
+       my_sys_siglist[SIGCHLD] = "Child exited";
+#endif
+#ifdef SIGCLD
+    if (my_sys_siglist[SIGCLD] == NULL)
+       my_sys_siglist[SIGCLD] = "Child exited";
+#endif
+#ifdef SIGTTIN
+    if (my_sys_siglist[SIGTTIN] == NULL)
+       my_sys_siglist[SIGTTIN] = "Stopped (tty input)";
+#endif
+#ifdef SIGTTOU
+    if (my_sys_siglist[SIGTTOU] == NULL)
+       my_sys_siglist[SIGTTOU] = "Stopped (tty output)";
+#endif
+#ifdef SIGINFO
+    if (my_sys_siglist[SIGINFO] == NULL)
+       my_sys_siglist[SIGINFO] = "Information request";
+#endif
+#ifdef SIGURG
+    if (my_sys_siglist[SIGURG] == NULL)
+       my_sys_siglist[SIGURG] = "Urgent I/O condition";
+#endif
+#ifdef SIGWAITING
+    if (my_sys_siglist[SIGWAITING] == NULL)
+       my_sys_siglist[SIGWAITING] = "No runnable LWPs";
+#endif
+#ifdef SIGLWP
+    if (my_sys_siglist[SIGLWP] == NULL)
+       my_sys_siglist[SIGLWP] = "Inter-LWP signal";
+#endif
+#ifdef SIGFREEZE
+    if (my_sys_siglist[SIGFREEZE] == NULL)
+       my_sys_siglist[SIGFREEZE] = "Checkpoint freeze";
+#endif
+#ifdef SIGTHAW
+    if (my_sys_siglist[SIGTHAW] == NULL)
+       my_sys_siglist[SIGTHAW] = "Checkpoint thaw";
+#endif
+#ifdef SIGCANCEL
+    if (my_sys_siglist[SIGCANCEL] == NULL)
+       my_sys_siglist[SIGCANCEL] = "Thread cancellation";
+#endif
diff --git a/siglist.in b/siglist.in
new file mode 100644 (file)
index 0000000..f149eb5
--- /dev/null
@@ -0,0 +1,56 @@
+#
+# List of signals used to build sys_siglist (see mksiglist.c)
+# Adapted from pdksh; public domain
+#
+# Note that if a system has multiple defines for the same signal
+# (eg, SIGABRT vs SIGIOT, SIGCHLD vs SIGCLD), only the first one
+# will be seen, so the order in this list is important.
+#
+    HUP     Hangup
+    INT     Interrupt
+    QUIT    Quit
+    ILL     Illegal instruction
+    TRAP    Trace trap
+# before IOT (ABRT is posix and ABRT is sometimes the same as IOT)
+    ABRT    Abort
+    IOT     IOT instruction
+    EMT     EMT trap
+    FPE     Floating point exception
+    KILL    Killed
+# before BUS (Older Linux doesn't really have a BUS, but defines it to UNUSED)
+    UNUSED  Unused
+    BUS     Bus error
+    SEGV    Memory fault
+    SYS     Bad system call
+    PIPE    Broken pipe
+    ALRM    Alarm clock
+    TERM    Terminated
+    STKFLT  Stack fault
+# before POLL (POLL is sometimes the same as IO)
+    IO      I/O possible
+    XCPU    CPU time limit exceeded
+    XFSZ    File size limit exceeded
+    VTALRM  Virtual timer expired
+    PROF    Profiling timer expired
+    WINCH   Window size change
+    LOST    File lock lost
+    USR1    User defined signal 1
+    USR2    User defined signal 2
+    PWR     Power-fail/Restart
+    POLL    Pollable event occurred
+    STOP    Stopped (signal)
+    TSTP    Stopped
+    CONT    Continued
+# before CLD (CHLD is posix and CHLD is sometimes the same as CLD)
+    CHLD    Child exited
+    CLD     Child exited
+    TTIN    Stopped (tty input)
+    TTOU    Stopped (tty output)
+    INFO    Information request
+    URG     Urgent I/O condition
+# Solaris (svr4?) signals
+    WAITING No runnable LWPs
+    LWP            Inter-LWP signal
+    FREEZE  Checkpoint freeze
+    THAW    Checkpoint thaw
+    CANCEL  Thread cancellation
index bca8ec6dd9bee8328ce6566cceba3eec5508eb4a..f243015dad15d1cee4cb07615be143b8615ea4a7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 2009-2010 Todd C. Miller <Todd.Miller@courtesan.com>
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
 #include <config.h>
 #include <compat.h>
 
+#if !defined(NSIG)
+# if defined(_NSIG)
+#  define NSIG _NSIG
+# elif defined(__NSIG)
+#  define NSIG __NSIG
+# else
+#  error one of NSIG, _NSIG, or __NSIG must be defined
+# endif
+#endif
+
+#if defined(HAVE_DECL_SYS_SIGLIST) && HAVE_DECL_SYS_SIGLIST == 1
+# define my_sys_siglist        sys_siglist
+#elif defined(HAVE_DECL__SYS_SIGLIST) && HAVE_DECL__SYS_SIGLIST == 1
+# define my_sys_siglist        _sys_siglist
+#elif defined(HAVE_DECL___SYS_SIGLIST) && HAVE_DECL___SYS_SIGLIST == 1
+# define my_sys_siglist        __sys_siglist
+#else
+extern const char *const my_sys_siglist[NSIG];
+#endif
+
 /*
  * Get signal description string
  */
@@ -27,9 +47,7 @@ char *
 strsignal(signo)
     int signo;
 {
-    extern const char *const sys_siglist[];
-
     if (signo > 0 && signo < NSIG)
-       return((char *)sys_siglist[signo]);
+       return((char *)my_sys_siglist[signo]);
     return("Unknown signal");
 }