Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
ksh is broken
Hi,
ksh is broken due to changes made in bin/ksh/siglist.sh Rev 1.10:
% ksh
$ /bin/echo a
a
(then, ksh is permanently trapped in __sigsuspend14)
This is because siglist.out, which is generated by siglist.sh, is not
sorted, and SIGABRT = SIGIOT = 6 appears two times. The followings are
codes from bin/ksh/trap.c, which apparently fails with siglist.out
which is not sorted or has duplicated entries:
Trap sigtraps[SIGNALS+1] = {
{ .signal = SIGEXIT_, .name = "EXIT", .mess = "Signal 0" },
#include "siglist.out" /* generated by siglist.sh */
{ .signal = SIGERR_, .name = "ERR", .mess = "Error handler" },
};
...
sigtraps[SIGINT].flags |= TF_DFL_INTR | TF_TTY_INTR;
sigtraps[SIGQUIT].flags |= TF_DFL_INTR | TF_TTY_INTR;
sigtraps[SIGTERM].flags |= TF_DFL_INTR;/* not fatal for interactive */
sigtraps[SIGHUP].flags |= TF_FATAL;
sigtraps[SIGCHLD].flags |= TF_SHELL_USES;
/* these are always caught so we can clean up any temporary files. */
setsig(&sigtraps[SIGINT], trapsig, SS_RESTORE_ORIG);
setsig(&sigtraps[SIGQUIT], trapsig, SS_RESTORE_ORIG);
setsig(&sigtraps[SIGTERM], trapsig, SS_RESTORE_ORIG);
setsig(&sigtraps[SIGHUP], trapsig, SS_RESTORE_ORIG);
...
I guess that siglist.sh Rev 1.10 is a work around for gcc 5, whose cpp
generates noisy output. Here I attached another work around based on
siglist.sh Rev 1.9. It is kind of an ugly hack, but at least works with
both gcc 4.8 and 5.3.
Thanks,
Rin
--- src/bin/ksh/siglist.sh.orig 2016-03-17 18:00:58.417246411 +0900
+++ src/bin/ksh/siglist.sh 2016-03-17 19:59:45.141415176 +0900
@@ -1,14 +1,46 @@
#!/bin/sh
-# $NetBSD: siglist.sh,v 1.10 2016/03/16 23:01:33 christos Exp $
+# $NetBSD: siglist.sh,v 1.9 2011/01/23 17:11:55 hauke Exp $
#
# Script to generate a sorted, complete list of signals, suitable
# for inclusion in trap.c as array initializer.
#
+set -e
+
+: ${AWK:=awk}
: ${SED:=sed}
-# The trap here to make up for a bug in bash (1.14.3(1)) that calls the trap
+in=tmpi$$.c
+out=tmpo$$.c
+ecode=1
+trapsigs='0 1 2 13 15'
+trap 'rm -f $in $out; trap 0; exit $ecode' $trapsigs
-${SED} -e '/^[ ]*#/d' -e 's/^[ ]*\([^ ][^ ]*\)[ ][ ]*\(.*[^ ]\)[ ]*$/#ifdef SIG\1\
- { .signal = SIG\1 , .name = "\1", .mess = "\2" },\
-#endif/'
+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" },';
+ ${SED} -e '/^[ ]*#/d' -e 's/^[ ]*\([^ ][^ ]*\)[ ][ ]*\(.*[^ ]\)[ ]*$/#ifdef SIG\1\
+ { QwErTy .signal = SIG\1 , .name = "\1", .mess = "\2" },\
+#endif/') > $in
+# work around for gcc 5
+$CPP $in | grep -v '^#' | tr -d '\n' | sed 's/},/},\
+/g' > $out
+${SED} -n 's/{ QwErTy/{/p' < $out | ${AWK} '{print NR, $0}' | sort -k 5n -k 1n |
+ ${SED} 's/^[0-9]* //' |
+ ${AWK} 'BEGIN { last=0; nsigs=0; }
+ {
+ if ($4 ~ /^[0-9][0-9]*$/ && $5 == ",") {
+ n = $4;
+ if (n > 0 && n != last) {
+ while (++last < n) {
+ printf "\t{ .signal = %d , .name = NULL, .mess = `Signal %d` } ,\n", last, last;
+ }
+ print;
+ }
+ }
+ }' |
+ tr '`' '"' | grep -v '"DUMMY"'
+ecode=0
Home |
Main Index |
Thread Index |
Old Index