summaryrefslogtreecommitdiff
path: root/tests/misc/timeout-group
diff options
context:
space:
mode:
Diffstat (limited to 'tests/misc/timeout-group')
-rwxr-xr-xtests/misc/timeout-group21
1 files changed, 16 insertions, 5 deletions
diff --git a/tests/misc/timeout-group b/tests/misc/timeout-group
index fedd53a60..5d31551d3 100755
--- a/tests/misc/timeout-group
+++ b/tests/misc/timeout-group
@@ -40,15 +40,25 @@ chmod a+x timeout.cmd
cat > group.sh <<\EOF
#!/bin/sh
-timeout --foreground 5 ./timeout.cmd 10&
+trap '' INT
+timeout --foreground 25 ./timeout.cmd 20&
wait
EOF
chmod a+x group.sh
+check_timeout_cmd_running()
+{
+ local delay="$1"
+ test -e timeout.running ||
+ { sleep $delay; return 1; }
+}
+
+
# Start above script in its own group.
# We could use timeout for this, but that assumes an implementation.
setsid ./group.sh &
-until test -e timeout.running; do sleep .1; done
+# Wait 6.3s for timeout.cmd to start
+retry_delay_ check_timeout_cmd_running .1 6 || fail=1
# Simulate a Ctrl-C to the group to test timely exit
# Note dash doesn't support signalling groups (a leading -)
env kill -INT -- -$!
@@ -66,9 +76,10 @@ rm -f int.received timeout.running
# Note the first timeout must send a signal that
# the second is handling for it to be propagated to the command.
# SIGINT, SIGTERM, SIGALRM etc. are implicit.
-timeout -sALRM 2 timeout -sINT 10 ./timeout.cmd 5&
-until test -e timeout.running; do sleep .1; done
-kill -ALRM $!
+timeout -sALRM 30 timeout -sINT 25 ./timeout.cmd 20&
+# Wait 6.3s for timeout.cmd to start
+retry_delay_ check_timeout_cmd_running .1 6 || fail=1
+kill -ALRM $! # trigger the alarm of the first timeout command
wait
test -e int.received || fail=1