From de2397fece839ce90f71e0624f5435755ad9ea01 Mon Sep 17 00:00:00 2001 From: Ángel González Date: Mon, 29 Oct 2012 00:36:08 +0000 Subject: timeout: add --preserve-status to always propagate the exit status It's useful for commands that support running for an indeterminite amount of time, to not return a specific timeout exit status (124), and instead let the command handle the timeout signal and return a status for the work done so far. * doc/coreutils.texi (timeout invocation): Describe the new option. * src/timeout.c (preserve_status): A new global boolean to enable the --preserve-status behavior. (usage): Describe the new option. (main): Don't return EXIT_TIMEOUT of preserve_status is set. * tests/misc/timeout.sh: Add a test for the new option. --- tests/misc/timeout.sh | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests/misc') diff --git a/tests/misc/timeout.sh b/tests/misc/timeout.sh index 57a4e15d0..66d69566e 100755 --- a/tests/misc/timeout.sh +++ b/tests/misc/timeout.sh @@ -36,6 +36,11 @@ test $? = 2 || fail=1 timeout 1 sleep 10 test $? = 124 || fail=1 +# exit status propagation even on timeout +timeout --preserve-status 1 sleep 10 +# exit status should be 128+TERM +test $? = 124 && fail=1 + # kill delay. Note once the initial timeout triggers, # the exit status will be 124 even if the command # exits on its own accord. -- cgit v1.2.3-70-g09d2