automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

signal handling (was: prepare Automake's test suite for parallelization)


From: Ralf Wildenhues
Subject: signal handling (was: prepare Automake's test suite for parallelization)
Date: Mon, 12 Nov 2007 19:42:28 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

* Ralf Wildenhues wrote on Sat, Nov 10, 2007 at 11:13:45AM CET:
> 
> BTW, there is one thing about the Automake test suite that has been
> bothering me for a long time: you often cannot interrupt it with ^C.
> I usually keep it pressed until one of the repeated interrupts finally
> kills the testing.  I've never been able to spot why exactly that is,
> I assume the non-interruptability of aclocal is a problem here.
> I don't even know why that is the case.  Hmm.

Ahh.  More head scratching.  I'd appreciate if somebody could
look over these two proposed patches to see if what I think how
signals ought to work makes sense.

For one: the "trap ''" does what I want on GNU/Linux: avoid infinite
recursion, and cause the whole test suite to be interrupted upon ^C.[1]
But I'm not sure if, on some other system, it may just cause the
interrupt to be ignored completely.

Anyway, with these two patches it seems to be reliably possible to
stop `make check' with one Control-C.

I would like to cherry-pick the aclocal change into branch-1-10.

Thanks,
Ralf

[1] BTW, this just provides _the_ reason to not factor the testsuite
cleanup of third-party TESTS users into Automake: they may want to
handle interrupts in their suite, and we certainly should not interfere
with that.


    Fix signal handling in the Automake test suite.
    
    * tests/defs.in: If the trap was invoked by a signal,
    then reraise the signal after cleanup.  Restore original
    exit status before, and "trap ''", as "trap -" is not
    portable.  Also, fix typo $me not $as_me.

diff --git a/tests/defs.in b/tests/defs.in
index d79d874..c81bf63 100644
--- a/tests/defs.in
+++ b/tests/defs.in
@@ -248,9 +248,13 @@ trap 'exit_status=$?
     chmod -R a+rwx $testSubDir > /dev/null 2>&1
     rm -rf "$testSubDir" ;;
   esac
-  test "$signal" != 0 &&
-    echo "$as_me: caught signal $signal"
-  echo "$as_me: exit $exit_status"
+  test "$signal" != 0 && {
+    echo "$me: caught signal $signal"
+    trap '' $signal
+    (exit $exit_status)
+    kill -$signal $$
+  }
+  echo "$me: exit $exit_status"
   exit $exit_status
 ' 0
 for signal in 1 2 13 15; do




    Fix signal handling in aclocal.
    
    * aclocal.in (unlink_tmp): If invoked by a signal, note so
    in verbose mode.  Reinstall default signal handler and reraise,
    to transport the interrupt information.

diff --git a/aclocal.in b/aclocal.in
index eac545f..a34fcd8 100644
--- a/aclocal.in
+++ b/aclocal.in
@@ -150,14 +150,27 @@ my $erase_me;
 
 ################################################################
 
-# Erase temporary file ERASE_ME.
+# Erase temporary file ERASE_ME.  Handle signals.
 sub unlink_tmp
 {
+  my ($sig) = @_;
+
+  if ($sig)
+    {
+      verb "caught SIG$sig, bailing out";
+    }
   if (defined $erase_me && -e $erase_me && !unlink ($erase_me))
     {
       fatal "could not remove `$erase_me': $!";
     }
   undef $erase_me;
+  
+  # reraise default handler.
+  if ($sig)
+    {
+      $SIG{$sig} = 'DEFAULT';
+      kill $sig => $$;
+    }
 }
 
 $SIG{'INT'} = $SIG{'TERM'} = $SIG{'QUIT'} = $SIG{'HUP'} = 'unlink_tmp';




reply via email to

[Prev in Thread] Current Thread [Next in Thread]