From 71cd8e3a743046573744123777061b64881bf372 Mon Sep 17 00:00:00 2001 From: Igor Pashev Date: Sat, 4 Jul 2015 17:13:50 +0300 Subject: Imported Upstream version 8.24 --- tests/misc/timeout-group.sh | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'tests/misc/timeout-group.sh') diff --git a/tests/misc/timeout-group.sh b/tests/misc/timeout-group.sh index 23c1b065..d47f0dc8 100755 --- a/tests/misc/timeout-group.sh +++ b/tests/misc/timeout-group.sh @@ -1,7 +1,7 @@ #!/bin/sh # test program group handling -# Copyright (C) 2011-2014 Free Software Foundation, Inc. +# Copyright (C) 2011-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -30,8 +30,8 @@ print_ver_ timeout setsid true || skip_ "setsid required to control groups" -cat > timeout.cmd <<\EOF -#!/bin/sh +printf '%s\n' '#!'"$SHELL" > timeout.cmd || framework_failure_ +cat >> timeout.cmd <<\EOF trap 'touch int.received; exit' INT touch timeout.running count=$1 @@ -42,8 +42,8 @@ done EOF chmod a+x timeout.cmd -cat > group.sh <<\EOF -#!/bin/sh +cat > group.sh </dev/null && wait $pid; } # Start above script in its own group. # We could use timeout for this, but that assumes an implementation. -setsid ./group.sh & +setsid ./group.sh & pid=$! # 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 -- -$! +env kill -INT -- -$pid wait test -e int.received || fail=1 @@ -82,8 +84,7 @@ start=$(date +%s) # 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 30 timeout -sINT 25 ./timeout.cmd 20& -pid=$! +timeout -sALRM 30 timeout -sINT 25 ./timeout.cmd 20 & pid=$! # Wait 6.3s for timeout.cmd to start retry_delay_ check_timeout_cmd_running .1 6 || fail=1 kill -ALRM $pid # trigger the alarm of the first timeout command -- cgit v1.2.3