From e8307f4a4559e52f16841c6e18e1c2bce8d693c9 Mon Sep 17 00:00:00 2001 From: tg Date: Fri, 31 Dec 2004 19:24:20 +0000 Subject: [PATCH] get rid of manually generated signal lists --- Build.sh | 10 ++++------ Makefile | 9 ++------- README | 6 ++---- siglist.in | 57 ------------------------------------------------------ siglist.sh | 41 --------------------------------------- trap.c | 36 ++++++++++++++-------------------- 6 files changed, 23 insertions(+), 136 deletions(-) delete mode 100644 siglist.in delete mode 100644 siglist.sh diff --git a/Build.sh b/Build.sh index cddd60a..7d52030 100644 --- a/Build.sh +++ b/Build.sh @@ -1,5 +1,5 @@ #!/bin/sh -# $MirBSD: src/bin/ksh/Build.sh,v 2.4 2004/12/18 18:58:30 tg Exp $ +# $MirBSD: src/bin/ksh/Build.sh,v 2.5 2004/12/31 19:24:20 tg Exp $ #- # Copyright (c) 2004 # Thorsten "mirabile" Glaser @@ -41,15 +41,13 @@ COPTS="-O2 -fomit-frame-pointer -fno-strict-aliasing -fno-strength-reduce" [ -z "$WEIRD_OS" ] && LDFLAGS="${LDFLAGS:--static}" if test -e strlfun.c; then - echo "Preparing testsuite..." - for hdr in errno signal; do - h2ph -d . /usr/include/$hdr.h && mv _h2ph_pre.ph $hdr.ph - done echo "Configuring..." $SHELL ./configure echo "Generating prerequisites..." - $SHELL ./siglist.sh "$CC -E $CPPFLAGS" siglist.out $SHELL ./emacs-gen.sh emacs.c >emacs.out + for hdr in errno signal; do + h2ph -d . /usr/include/$hdr.h && mv _h2ph_pre.ph $hdr.ph + done echo "Building..." $CC $COPTS $CFLAGS $CPPFLAGS $LDFLAGS -o mksh *.c test -e mksh || exit 1 diff --git a/Makefile b/Makefile index 5001787..3f752b7 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# $MirBSD: src/bin/ksh/Makefile,v 2.4 2004/12/18 18:58:30 tg Exp $ +# $MirBSD: src/bin/ksh/Makefile,v 2.5 2004/12/31 19:24:20 tg Exp $ # $OpenBSD: Makefile,v 1.18 2004/02/16 19:07:19 deraadt Exp $ PROG= ksh @@ -9,19 +9,14 @@ MAN= ksh.1tbl sh.1tbl CPPFLAGS+= -DHAVE_CONFIG_H -I. -DMIRBSD_NATIVE CFLAGS+= -Wall -Werror -W -pedantic -CLEANFILES+= siglist.out emacs.out +CLEANFILES+= emacs.out LINKS= ${BINDIR}/ksh ${BINDIR}/rksh LINKS+= ${BINDIR}/ksh ${BINDIR}/sh MLINKS= ksh.1 rksh.1 ksh.1 ulimit.1 -.depend trap.o: siglist.out .depend emacs.o: emacs.out -siglist.out: config.h sh.h siglist.in siglist.sh - ${SHELL} ${.CURDIR}/siglist.sh \ - "${CC} -E ${CPPFLAGS}" <${.CURDIR}/siglist.in >siglist.out - emacs.out: emacs.c ${SHELL} ${.CURDIR}/emacs-gen.sh ${.CURDIR}/emacs.c >emacs.out diff --git a/README b/README index 209495c..4820dfb 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -$MirBSD: src/bin/ksh/README,v 2.3 2004/12/13 18:53:25 tg Exp $ +$MirBSD: src/bin/ksh/README,v 2.4 2004/12/31 19:24:20 tg Exp $ This is the README for mirbsdksh, developed as part of the MirBSD operating system at The MirOS Project, and produced portably. @@ -19,9 +19,7 @@ This package as a whole is placed under the MirOS licence template as contained in the "Build.sh" source file in this distribution, by having the project leader asserting a collective copyright. -The files alloc.c (Marc Espie), ksh.1tbl and sh.1tbl (University of -California, Berkeley) are provided under a 2-clause or 3-clause BSD -licence, respectively. +The file alloc.c by Marc Espie is provided under a 2-clause BSD licence. All files from the original pdksh distribution which were not public domain have been removed from the source tree, with the exception of diff --git a/siglist.in b/siglist.in deleted file mode 100644 index 696a276..0000000 --- a/siglist.in +++ /dev/null @@ -1,57 +0,0 @@ -# $MirBSD: src/bin/ksh/siglist.in,v 2.1 2004/12/10 18:09:42 tg Exp $ -# $OpenBSD: siglist.in,v 1.1.1.1 1996/08/14 06:19:11 downsj Exp $ -# -# List of signals used to initialize ksh's signal table (see trap.c -# and siglist.sh). -# -# 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 (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 diff --git a/siglist.sh b/siglist.sh deleted file mode 100644 index 6fe6248..0000000 --- a/siglist.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh -# $MirBSD: src/bin/ksh/siglist.sh,v 2.2 2004/12/18 19:22:30 tg Exp $ -# $OpenBSD: siglist.sh,v 1.4 1997/06/19 13:58:47 kstailey Exp $ -# -# Script to generate a sorted, complete list of signals, suitable -# for inclusion in trap.c as array initializer. - -set -e - -in=tmpi$$.c -out=tmpo$$.c -ecode=1 -trapsigs='0 1 2 13 15' -trap 'rm -f $in $out; trap 0; exit $ecode' $trapsigs - -CPP="${1-cc -E}" - -# The trap here to make up for a bug in bash (1.14.3(1)) that calls the trap -(trap $trapsigs; - echo '#include "sh.h"'; - echo ' { QwErTy SIGNALS , "DUMMY" , "hook for number of signals", 0, 0, 0, 0, 0 },'; - sed -e '/^[ ]*#/d' -e 's/^[ ]*\([^ ][^ ]*\)[ ][ ]*\(.*[^ ]\)[ ]*$/#ifdef SIG\1\ - { QwErTy SIG\1 , "\1", "\2", 0, 0, 0, 0, 0 },\ -#endif/') > $in -$CPP $in > $out -sed -n 's/{ QwErTy/{/p' < $out | awk '{print NR, $0}' | sort +2n +0n | - sed 's/^[0-9]* //' | - awk 'BEGIN { last=0; nsigs=0; } - { - if ($2 ~ /^[0-9][0-9]*$/ && $3 == ",") { - n = $2; - if (n > 0 && n != last) { - while (++last < n) { - printf "\t{ %d , NULL, `Signal %d` } ,\n", last, last; - } - print; - } - } - }' | - tr '`' '"' | grep -v '"DUMMY"' -ecode=0 diff --git a/trap.c b/trap.c index 0a0178f..af36777 100644 --- a/trap.c +++ b/trap.c @@ -1,5 +1,5 @@ -/** $MirBSD: src/bin/ksh/trap.c,v 2.5 2004/12/31 17:29:28 tg Exp $ */ -/* $OpenBSD: trap.c,v 1.17 2004/12/18 21:58:39 millert Exp $ */ +/** $MirBSD: src/bin/ksh/trap.c,v 2.6 2004/12/31 19:24:20 tg Exp $ */ +/* $OpenBSD: trap.c,v 1.19 2004/12/22 17:47:03 millert Exp $ */ /* * signal handling @@ -9,35 +9,29 @@ #define FROM_TRAP_C #include "sh.h" -__RCSID("$MirBSD: src/bin/ksh/trap.c,v 2.5 2004/12/31 17:29:28 tg Exp $"); +__RCSID("$MirBSD: src/bin/ksh/trap.c,v 2.6 2004/12/31 19:24:20 tg Exp $"); -/* Table is indexed by signal number - * - * The script siglist.sh generates siglist.out, which is a sorted, complete - * list of signals - */ -Trap sigtraps[NSIG + 1] = { - { SIGEXIT_, "EXIT", "Signal 0", NULL, 0, 0, 0, 0 }, -#include "siglist.out" /* generated by siglist.sh */ - { SIGERR_, "ERR", "Error handler", NULL, 0, 0, 0, 0 }, - }; +Trap sigtraps[NSIG + 1]; static struct sigaction Sigact_ign, Sigact_trap; void inittraps(void) { -#ifdef HAVE_SYS_SIGLIST -# ifndef SYS_SIGLIST_DECLARED - extern char *sys_siglist[]; -# endif int i; - /* Use system description, if available, for unknown signals... */ - for (i = 0; i < NSIG; i++) - if (!sigtraps[i].name && sys_siglist[i] && sys_siglist[i][0]) + /* Populate sigtraps based on sys_signame and sys_siglist. */ + for (i = 0; i <= NSIG; i++) { + sigtraps[i].signal = i; + if (i == SIGERR_) { + sigtraps[i].name = "ERR"; + sigtraps[i].mess = "Error handler"; + } else { + sigtraps[i].name = sys_signame[i]; sigtraps[i].mess = sys_siglist[i]; -#endif /* HAVE_SYS_SIGLIST */ + } + } + sigtraps[SIGEXIT_].name = "EXIT"; /* our name for signal 0 */ sigemptyset(&Sigact_ign.sa_mask); Sigact_ign.sa_flags = 0; /* interruptible */