From 38509d0e217d57d9b7fb18727bd02277cd205566 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 13 Sep 2019 15:33:04 -0700 Subject: timeout: fix exit status for sneaky subprocesses. There's nothing to stop a subprocess from catching our SIGTERM on timeout and exiting, causing us to incorrectly report that it didn't time out. Android's ART has a utility that does exactly this. Explicitly catch this case, and add corresponding tests. Bug: http://b/141007616 --- tests/timeout.test | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests') diff --git a/tests/timeout.test b/tests/timeout.test index 189b592a..18f93790 100644 --- a/tests/timeout.test +++ b/tests/timeout.test @@ -18,3 +18,18 @@ testcmd "exit 1" '.1 false ; echo $?' '1\n' '' '' testcmd "--preserve-status" '--preserve-status .1 sleep 100 ; echo $?' '143\n' '' '' testcmd "--preserve-status killed" '--preserve-status -s 9 .1 sleep 100 ; echo $?' '137\n' '' '' + +# There's another special case where if the subprocess catches our timeout +# signal and exits, we need to report that as a timeout (unless overridden). +cat > loop.sh <