summaryrefslogtreecommitdiff
path: root/tests/misc
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2009-12-07 19:00:04 +0000
committerPádraig Brady <P@draigBrady.com>2009-12-08 15:17:01 +0000
commit73d46261344d5bd05c0940bc2ec5f9ed9a47db1b (patch)
treea8f47c3c6d786de38da1688a8af5b920be31de6a /tests/misc
parent7ac41f995014067dd4f9eb6f75875f44f761e49a (diff)
downloadcoreutils-73d46261344d5bd05c0940bc2ec5f9ed9a47db1b.tar.xz
timeout: fix failure if timeout's parent has ignored SIGCHLD
* src/timeout.c (main): Reset the SIGCHLD handler to the default as otherwise wait() could return -1 and set errno to ECHILD. This condition was ignored until commit 0b1dcf33, on 31-08-2009, "timeout: defensive handling of all wait() errors" but subsequently timeout would run the command correctly but then fail with an error message. * tests/misc/timeout: In a subshell set the CHLD handler to SIG_IGN to ensure the timeout command resets it to SIG_DFL. * NEWS: Mention the fix.
Diffstat (limited to 'tests/misc')
-rwxr-xr-xtests/misc/timeout11
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/misc/timeout b/tests/misc/timeout
index 77a42053b..aae45f7f9 100755
--- a/tests/misc/timeout
+++ b/tests/misc/timeout
@@ -23,7 +23,6 @@ fi
. $srcdir/test-lib.sh
-
# no timeout
timeout 1 true || fail=1
@@ -42,4 +41,14 @@ test $? = 2 || fail=1
timeout 1 sleep 2
test $? = 124 || fail=1
+# Ensure `timeout` is immune to parent's SIGCHLD handler
+# Use a subshell and an exec to work around a bug in FreeBSD 5.0 /bin/sh.
+(
+ # ash doesn't support "trap '' CHLD"; it knows only signal numbers.
+ sig=`"$abs_top_builddir/src/kill" -l CHLD 2>/dev/null` && trap '' $sig
+
+ # Before 2004-04-21, install would infloop, in the `while (wait...' loop:
+ exec timeout 1 true
+) || fail=1
+
Exit $fail