]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
test defs: work around weird ksh behaviour w.r.t. signal handling
authorStefano Lattarini <stefano.lattarini@gmail.com>
Mon, 12 Sep 2011 23:01:46 +0000 (01:01 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Tue, 13 Sep 2011 08:07:16 +0000 (10:07 +0200)
* 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:
 <http://lists.gnu.org/archive/html/bug-autoconf/2011-09/msg00004.html>
 <http://mail.opensolaris.org/pipermail/ksh93-integration-discuss/2009-February/004121.html>
 <http://www.cons.org/cracauer/sigint.html>

ChangeLog
tests/defs

index 9b98bfd64d32cceea8d03d2d78684a81b8848966..cbc669319636e10f8a137be4e120d6db7a28b8d0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2011-09-13  Stefano Lattarini  <stefano.lattarini@gmail.com>
+
+       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:
+        <http://lists.gnu.org/archive/html/bug-autoconf/2011-09/msg00004.html>
+        <http://mail.opensolaris.org/pipermail/ksh93-integration-discuss/2009-February/004121.html>
+        <http://www.cons.org/cracauer/sigint.html>
+
 2011-09-12  Stefano Lattarini  <stefano.lattarini@gmail.com>
 
        tests: remove redundant line from a test script
index cbeccb981cecaf3eabc51ab6061367f5d31f21e4..9fed42e4cc4c0339a002d36ed8c3b7ccf1ba7f88 100644 (file)
@@ -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:
+  # <http://lists.gnu.org/archive/html/bug-autoconf/2011-09/msg00004.html>
+  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...]