summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2012-12-18 13:06:15 +0000
committerPádraig Brady <P@draigBrady.com>2012-12-19 11:32:07 +0000
commit751a4c4d036d83b98ac39cfcb2de4de10f1139e1 (patch)
treef3a018a71760f76ec97ee3d03defc52e14899e5d
parent82b1728c4b03f80c56eae0f59d0e9a75e3d2bf9f (diff)
downloadcoreutils-751a4c4d036d83b98ac39cfcb2de4de10f1139e1.tar.xz
tests: avoid a race in timeout-group.sh
* tests/misc/timeout-group.sh: The kernel might possibly delay signal propagation to timeout.cmd long enough, that it exits normally without running the signal handler (as sleep will be in the same process group and so get the signal too). So avoid this by explicitly checking that the signal handler is called, which should always happen under normal circumstances. Reported by Stefano Lattarini on linux-2.6.30-2-686 and bash-4.2.36.
-rwxr-xr-xtests/misc/timeout-group.sh6
1 files changed, 5 insertions, 1 deletions
diff --git a/tests/misc/timeout-group.sh b/tests/misc/timeout-group.sh
index 4cefc33bf..7117abb5a 100755
--- a/tests/misc/timeout-group.sh
+++ b/tests/misc/timeout-group.sh
@@ -34,7 +34,11 @@ cat > timeout.cmd <<\EOF
#!/bin/sh
trap 'touch int.received; exit' INT
touch timeout.running
-sleep $1
+count=$1
+until test -e int.received || test $count = 0; do
+ sleep 1
+ count=$(expr $count - 1)
+done
EOF
chmod a+x timeout.cmd