bug-gnulib
[Top][All Lists]
Advanced

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

[PATCH] init.sh: ensure a more reliable exit status when exiting via tra


From: Jim Meyering
Subject: [PATCH] init.sh: ensure a more reliable exit status when exiting via trap
Date: Wed, 28 Apr 2010 10:02:03 +0200

I've fixed the trap code in init.sh.
Thanks, Dmitry.

>From 092a81622804491f13fb73f4df610db0db45b35a Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Wed, 28 Apr 2010 09:51:15 +0200
Subject: [PATCH] init.sh: ensure a more reliable exit status when exiting via 
trap

* tests/init.sh (setup_): Don't rely on $? in signal handler.
Inspired by patches from Dmitry V. Levin.
Also trap on signal 3 (SIGQUIT).
---
 ChangeLog     |    7 +++++++
 tests/init.sh |    8 +++++---
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f73dc44..1191a67 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-04-28  Jim Meyering  <address@hidden>
+
+       init.sh: ensure a more reliable exit status when exiting via trap
+       * tests/init.sh (setup_): Don't rely on $? in signal handler.
+       Inspired by patches from Dmitry V. Levin.
+       Also trap on signal 3 (SIGQUIT).
+
 2010-04-27  Bruno Haible  <address@hidden>

        Update doc about utimes().
diff --git a/tests/init.sh b/tests/init.sh
index ee9c542..512e876 100644
--- a/tests/init.sh
+++ b/tests/init.sh
@@ -225,10 +225,12 @@ setup_()
     || fail_ "failed to create temporary directory in $initial_cwd_"
   cd "$test_dir_"

-  # This pair of trap statements ensures that the temporary directory,
-  # $test_dir_, is removed upon exit as well as upon catchable signal.
+  # These trap statements ensure that the temporary directory, $test_dir_,
+  # is removed upon exit as well as upon receipt of any of the listed signals.
   trap remove_tmp_ 0
-  trap 'Exit $?' 1 2 13 15
+  for sig_ in 1 2 3 13 15; do
+    eval "trap 'Exit $(expr $sig_ + 128)' $sig_"
+  done
 }

 # Create a temporary directory, much like mktemp -d does.
--
1.7.1.328.g9993c




reply via email to

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