From: Stefano Lattarini Date: Mon, 12 Sep 2011 23:01:46 +0000 (+0200) Subject: test defs: work around weird ksh behaviour w.r.t. signal handling X-Git-Tag: ng-0.5a~89^2~47 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=v1.11-1342-g6321ad3;p=thirdparty%2Fautomake.git test defs: work around weird ksh behaviour w.r.t. signal handling * tests/defs (is_blocked_signal): Use perl to determine whether a signal is trapped, since trying to do it portably within the shell means opening a nasty can of worms. For more information and background, see: --- diff --git a/ChangeLog b/ChangeLog index 9b98bfd64..cbc669319 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2011-09-13 Stefano Lattarini + + test defs: work around weird ksh behaviour w.r.t. signal handling + * tests/defs (is_blocked_signal): Use perl to determine whether a + signal is trapped, since trying to do it portably within the shell + means opening a nasty can of worms. + For more information and background, see: + + + + 2011-09-12 Stefano Lattarini tests: remove redundant line from a test script diff --git a/tests/defs b/tests/defs index cbeccb981..9fed42e4c 100644 --- a/tests/defs +++ b/tests/defs @@ -247,7 +247,23 @@ is_newest () # return a non-zero exit status and print a proper diagnostic otherwise. is_blocked_signal () { - $SHELL -c "kill -$1 \$\$; echo '$me: signal $1 seems blocked'" + # Use perl, since trying to do this portably in the shell can be + # very tricky, if not downright impossible. For reference, see: + # + if $PERL -w -e ' + use strict; + use warnings FATAL => "all"; + use POSIX; + my %oldsigaction = (); + sigaction('"$1"', 0, \%oldsigaction); + exit ($oldsigaction{"HANDLER"} eq "IGNORE" ? 0 : 77); + '; then + return 0 + elif test $? -eq 77; then + return 1 + else + fatal_ "couldn't determine whether signal $1 is blocked" + fi } # AUTOMAKE_run [-e STATUS] [-d DESCRIPTION] [--] [AUTOMAKE-ARGS...]