[DTrace-devel] [PATCH 10/12] Try an orderly shutdown if a test times out

eugene.loh at oracle.com eugene.loh at oracle.com
Sat Jul 11 17:38:34 PDT 2020


From: Eugene Loh <eugene.loh at oracle.com>

The test suite has a time-out mechanism.  Currently, it sends a
KILL signal, which does not allow DTrace to clean up after itself.

Use TERM for the time-out signal, since it (and INT) are captured
by DTrace and allow an orderly shutdown.  Specify as well that a
KILL signal should be sent if the command is still running a few
seconds after the initial signal.

The timeout return code is different depending on whether the first
or the KILL signal terminated the job, but runtest.sh already checks
this.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>
---
 runtest.sh | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/runtest.sh b/runtest.sh
index 7c0957ce..ad579ef1 100755
--- a/runtest.sh
+++ b/runtest.sh
@@ -81,14 +81,18 @@ ZAPTHESE=
 #
 # Run command CMD with argument ARGS, with the specified timeout.
 # Return the exitcode of the command, or $TIMEOUTRET if a timeout occurred.
+# Also send a KILL signal if the command is still running TIMEOUTKIL seconds
+# after the initial signal is sent, but start with TIMEOUTSIG so that DTrace
+# can perform an orderly shutdown, if possible.
 
-TIMEOUTSIG=KILL
+TIMEOUTSIG=TERM
 TIMEOUTRET=124
+TIMEOUTKIL=5
 
 run_with_timeout()
 {
     log "Running timeout --signal=$TIMEOUTSIG $@ ${explicit_arg:+"$explicit_arg"}\n"
-    timeout --signal=$TIMEOUTSIG $@ ${explicit_arg:+"$explicit_arg"}
+    timeout --signal=$TIMEOUTSIG --kill-after=$TIMEOUTKIL $@ ${explicit_arg:+"$explicit_arg"}
     local status=$?
 
     # short wait to allow any coredump to trickle out to disk.
-- 
2.18.2




More information about the DTrace-devel mailing list