diff options
author | Pádraig Brady <P@draigBrady.com> | 2011-07-08 13:31:05 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2011-07-08 13:54:08 +0100 |
commit | 4d90d29899917ec16ea5806a0456501e5e948960 (patch) | |
tree | 3af0b546d5b32d0fe761037546866ad9ff9a4621 /tests/misc/timeout-group | |
parent | 4496c94091f8a6bc95fc1c0868eba632fae99ba3 (diff) | |
download | coreutils-4d90d29899917ec16ea5806a0456501e5e948960.tar.xz |
timeout: support cascaded timeouts
* src/timeout.c (cleanup): Send signals directly to the child
in case it has started its own process group (like a cascaded
timeout command would for example).
* test/misc/timeout-group: Add a test case.
* NEWS: Mention the fix.
Diffstat (limited to 'tests/misc/timeout-group')
-rwxr-xr-x | tests/misc/timeout-group | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/tests/misc/timeout-group b/tests/misc/timeout-group index 0c3caa0f0..fedd53a60 100755 --- a/tests/misc/timeout-group +++ b/tests/misc/timeout-group @@ -34,13 +34,13 @@ cat > timeout.cmd <<\EOF #!/bin/sh trap 'touch int.received; exit' INT touch timeout.running -sleep 10 +sleep $1 EOF chmod a+x timeout.cmd cat > group.sh <<\EOF #!/bin/sh -timeout --foreground 5 ./timeout.cmd& +timeout --foreground 5 ./timeout.cmd 10& wait EOF chmod a+x group.sh @@ -55,4 +55,21 @@ env kill -INT -- -$! wait test -e int.received || fail=1 +rm -f int.received timeout.running + + +# Ensure cascaded timeouts work +# or more generally, ensure we timeout +# commands that create their own group +# This didn't work before 8.13. + +# 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 $! +wait +test -e int.received || fail=1 + Exit $fail |