aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@wdc.com>2020-06-11 02:30:44 +0100
committerJacob Bachmeyer <jcb62281+dev@gmail.com>2020-06-22 23:33:49 -0500
commit04668d6771f583c5b0a782e075acb71191c33b55 (patch)
tree36ea0b0f0d02dc600505102ff6a88ad578180384
parent5fafcd43b2d22b2227e62f7278584418c6449824 (diff)
downloaddejagnu-04668d6771f583c5b0a782e075acb71191c33b55.zip
dejagnu-04668d6771f583c5b0a782e075acb71191c33b55.tar.gz
dejagnu-04668d6771f583c5b0a782e075acb71191c33b55.tar.bz2
remote: Use `catch' in killing pending force-kills
Address an execution race in `close_wait_program' and use `catch' in killing pending force-kills issued there in the recovery of a stuck test case, in case the force-kill sequence has completed before the command to kill the sequence had a chance to run, so that no error is thrown and a testsuite run does not get interrupted early like: PASS: gcc.c-torture/execute/postmod-1.c -O0 (test for excess errors) Executing on remote-localhost: .../gcc/testsuite/gcc/postmod-1.exe (timeout = 15) spawn [open ...] WARNING: program timed out ERROR: tcl error sourcing .../gcc/testsuite/gcc.c-torture/execute/execute.exp. ERROR: child process exited abnormally while executing "exec sh -c "exec > /dev/null 2>&1 && kill -9 $exec_pid"" (procedure "close_wait_program" line 57) invoked from within "close_wait_program $spawn_id $pid wres" (procedure "local_exec" line 104) [...] "uplevel #0 source .../gcc/testsuite/gcc.c-torture/execute/execute.exp" invoked from within "catch "uplevel #0 source $test_file_name"" testcase .../gcc/testsuite/gcc.c-torture/execute/execute.exp completed in 196 seconds === gcc Summary === # of expected passes 1 -- therefore not letting `execute.exp' continue (here with the GCC `c' testsuite invoked with `execute.exp=postmod-1.c' for 8 compilation and 8 execution tests). The completion of the force-kill sequence would have to happen in the window between the `wait' command has returned, which would at worst happen as a result of the final `kill -9' command in the sequence, and the `kill -9 $exec_pid' command issued here, and the `sleep 5' command issued at the end of the force-kill sequence makes the likelihood of such a scenario low, but this might still happen with a loaded host system and there is no drawback from using `catch' here, so let's do it. * lib/remote.exp (close_wait_program): Use `catch' in killing pending force-kills. Signed-off-by: Maciej W. Rozycki <macro@wdc.com>
-rw-r--r--lib/remote.exp5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/remote.exp b/lib/remote.exp
index ce0d702..83472f7 100644
--- a/lib/remote.exp
+++ b/lib/remote.exp
@@ -113,7 +113,10 @@ proc close_wait_program { program_id pid {wres_varname ""} } {
# We reaped the process, so cancel the pending force-kills, as
# otherwise if the PID is reused for some other unrelated
# process, we'd kill the wrong process.
- exec sh -c "exec > /dev/null 2>&1 && kill -9 $exec_pid"
+ #
+ # Use `catch' in case the force-kills have completed, so as not
+ # to cause TCL to choke if `kill' returns a failure.
+ catch {exec sh -c "kill -9 $exec_pid" >& /dev/null}
}
return $res