Create our own sys_siglist for systems without it for use by strsignal()
This commit is contained in:
@@ -55,11 +55,22 @@ all: libreplace.la
|
||||
.SUFFIXES: .o .c .h .lo
|
||||
|
||||
.c.lo:
|
||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $<
|
||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(DEFS) $<
|
||||
|
||||
libreplace.la: $(LTLIBOBJS)
|
||||
$(LIBTOOL) --mode=link $(CC) -o $@ $(LTLIBOBJS) -no-install
|
||||
|
||||
$(LIBOBJDIR)siglist.c: $(LIBOBJDIR)mksiglist
|
||||
$(LIBOBJDIR)mksiglist > $@
|
||||
|
||||
$(LIBOBJDIR)mksiglist: $(LIBOBJDIR)mksiglist.c $(LIBOBJDIR)mksiglist.h $(incdir)/compat.h $(top_builddir)/config.h
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFS) $(LIBOBJDIR)mksiglist.c -o $@
|
||||
|
||||
@DEV@$(LIBOBJDIR)mksiglist.h: $(LIBOBJDIR)siglist.in
|
||||
@DEV@ awk '/^ [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))}' < $(LIBOBJDIR)siglist.in > $@
|
||||
|
||||
$(LIBOBJDIR)siglist.lo: $(LIBOBJDIR)siglist.c $(incdir)/compat.h $(top_builddir)/config.h
|
||||
|
||||
# Dependencies
|
||||
$(LIBOBJDIR)closefrom.lo: $(compat)/closefrom.c $(incdir)/compat.h $(top_builddir)/config.h
|
||||
$(LIBOBJDIR)fnmatch.lo: $(compat)/fnmatch.c $(compat)/fnmatch.h $(compat)/charclass.h $(incdir)/compat.h $(top_builddir)/config.h
|
||||
|
48
compat/mksiglist.c
Normal file
48
compat/mksiglist.c
Normal file
@@ -0,0 +1,48 @@
|
||||
#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(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);
|
||||
}
|
172
compat/mksiglist.h
Normal file
172
compat/mksiglist.h
Normal file
@@ -0,0 +1,172 @@
|
||||
#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
|
54
compat/siglist.in
Normal file
54
compat/siglist.in
Normal file
@@ -0,0 +1,54 @@
|
||||
#
|
||||
# List of signals used to build sys_siglist (see mksiglist.c)
|
||||
#
|
||||
# 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
|
||||
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
|
@@ -20,16 +20,6 @@
|
||||
#include <config.h>
|
||||
#include <compat.h>
|
||||
|
||||
#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
|
||||
# error one of HAVE_DECL_SYS_SIGLIST, HAVE_DECL__SYS_SIGLIST, HAVE_DECL___SYS_SIGLIST must be defined
|
||||
#endif
|
||||
|
||||
#if !defined(NSIG)
|
||||
# if defined(_NSIG)
|
||||
# define NSIG _NSIG
|
||||
@@ -40,6 +30,16 @@
|
||||
# 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
|
||||
*/
|
||||
|
49
configure
vendored
49
configure
vendored
@@ -21874,6 +21874,13 @@ _ACEOF
|
||||
|
||||
else
|
||||
|
||||
case " $LIBOBJS " in
|
||||
*" strsignal.$ac_objext "* ) ;;
|
||||
*) LIBOBJS="$LIBOBJS strsignal.$ac_objext"
|
||||
;;
|
||||
esac
|
||||
|
||||
HAVE_SIGLIST="false"
|
||||
{ echo "$as_me:$LINENO: checking whether sys_siglist is declared" >&5
|
||||
echo $ECHO_N "checking whether sys_siglist is declared... $ECHO_C" >&6; }
|
||||
if test "${ac_cv_have_decl_sys_siglist+set}" = set; then
|
||||
@@ -21937,16 +21944,7 @@ cat >>confdefs.h <<_ACEOF
|
||||
_ACEOF
|
||||
|
||||
|
||||
case " $LIBOBJS " in
|
||||
*" strsignal.$ac_objext "* ) ;;
|
||||
*) LIBOBJS="$LIBOBJS strsignal.$ac_objext"
|
||||
;;
|
||||
esac
|
||||
|
||||
cat >>confdefs.h <<\_ACEOF
|
||||
#define HAVE_STRSIGNAL 1
|
||||
_ACEOF
|
||||
|
||||
HAVE_SIGLIST="true"
|
||||
break
|
||||
|
||||
else
|
||||
@@ -22019,16 +22017,7 @@ cat >>confdefs.h <<_ACEOF
|
||||
_ACEOF
|
||||
|
||||
|
||||
case " $LIBOBJS " in
|
||||
*" strsignal.$ac_objext "* ) ;;
|
||||
*) LIBOBJS="$LIBOBJS strsignal.$ac_objext"
|
||||
;;
|
||||
esac
|
||||
|
||||
cat >>confdefs.h <<\_ACEOF
|
||||
#define HAVE_STRSIGNAL 1
|
||||
_ACEOF
|
||||
|
||||
HAVE_SIGLIST="true"
|
||||
break
|
||||
|
||||
else
|
||||
@@ -22101,16 +22090,7 @@ cat >>confdefs.h <<_ACEOF
|
||||
_ACEOF
|
||||
|
||||
|
||||
case " $LIBOBJS " in
|
||||
*" strsignal.$ac_objext "* ) ;;
|
||||
*) LIBOBJS="$LIBOBJS strsignal.$ac_objext"
|
||||
;;
|
||||
esac
|
||||
|
||||
cat >>confdefs.h <<\_ACEOF
|
||||
#define HAVE_STRSIGNAL 1
|
||||
_ACEOF
|
||||
|
||||
HAVE_SIGLIST="true"
|
||||
break
|
||||
|
||||
else
|
||||
@@ -22122,6 +22102,15 @@ _ACEOF
|
||||
fi
|
||||
|
||||
|
||||
if test "$HAVE_SIGLIST" != "true"; then
|
||||
case " $LIBOBJS " in
|
||||
*" siglist.$ac_objext "* ) ;;
|
||||
*) LIBOBJS="$LIBOBJS siglist.$ac_objext"
|
||||
;;
|
||||
esac
|
||||
|
||||
fi
|
||||
|
||||
fi
|
||||
done
|
||||
|
||||
|
13
configure.in
13
configure.in
@@ -2020,14 +2020,19 @@ dnl
|
||||
dnl Check for strsignal() or sys_siglist
|
||||
dnl
|
||||
AC_CHECK_FUNCS(strsignal, [], [
|
||||
AC_LIBOBJ(strsignal)
|
||||
HAVE_SIGLIST="false"
|
||||
AC_CHECK_DECLS([sys_siglist, _sys_siglist, __sys_siglist], [
|
||||
AC_LIBOBJ(strsignal)
|
||||
AC_DEFINE(HAVE_STRSIGNAL)
|
||||
HAVE_SIGLIST="true"
|
||||
break
|
||||
], [], [
|
||||
], [ ], [
|
||||
AC_INCLUDES_DEFAULT
|
||||
#include <signal.h>
|
||||
])])
|
||||
])
|
||||
if test "$HAVE_SIGLIST" != "true"; then
|
||||
AC_LIBOBJ(siglist)
|
||||
fi
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl nsswitch.conf and its equivalents
|
||||
|
@@ -75,7 +75,7 @@ int setenv(const char *, const char *, int);
|
||||
#ifndef HAVE_UNSETENV
|
||||
int unsetenv(const char *);
|
||||
#endif
|
||||
#if defined(HAVE_DECL_SYS_SIGLIST) || defined(HAVE_DECL__SYS_SIGLIST) || defined(HAVE_DECL___SYS_SIGLIST)
|
||||
#ifndef HAVE_STRSIGNAL
|
||||
char *strsignal(int);
|
||||
#endif
|
||||
#ifndef HAVE_STRDUP
|
||||
|
@@ -629,7 +629,6 @@ script_execve(struct command_details *details, char *argv[], char *envp[],
|
||||
}
|
||||
flush_output(&output);
|
||||
|
||||
#ifdef HAVE_STRSIGNAL
|
||||
if (cstat->type == CMD_WSTATUS && WIFSIGNALED(cstat->val)) {
|
||||
int signo = WTERMSIG(cstat->val);
|
||||
if (signo && signo != SIGINT && signo != SIGPIPE) {
|
||||
@@ -640,7 +639,6 @@ script_execve(struct command_details *details, char *argv[], char *envp[],
|
||||
write(STDOUT_FILENO, "\n", 1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
do {
|
||||
n = term_restore(script_fds[SFD_USERTTY], 0);
|
||||
} while (!n && errno == EINTR);
|
||||
|
Reference in New Issue
Block a user