aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJacob Bachmeyer <jcb62281+dev@gmail.com>2020-07-06 21:05:00 -0500
committerJacob Bachmeyer <jcb62281+dev@gmail.com>2020-07-06 21:05:00 -0500
commit4348c51f4e587974e1da5a32cd8cf1e0097ff8fd (patch)
tree46b86a8bb1138f7544c1ac4f1b707273766d3da6 /lib
parent376dacc26259cbd61860d58a3ec16099d5b7581f (diff)
parented7ed2891c051f8114db1a87b36aefd120fbfc0f (diff)
downloaddejagnu-4348c51f4e587974e1da5a32cd8cf1e0097ff8fd.zip
dejagnu-4348c51f4e587974e1da5a32cd8cf1e0097ff8fd.tar.gz
dejagnu-4348c51f4e587974e1da5a32cd8cf1e0097ff8fd.tar.bz2
Merge branch 'timeout-fix-for-1.6.3'
Conflicts: ChangeLog
Diffstat (limited to 'lib')
-rw-r--r--lib/remote.exp23
1 files changed, 21 insertions, 2 deletions
diff --git a/lib/remote.exp b/lib/remote.exp
index ce0d702..1c9971a 100644
--- a/lib/remote.exp
+++ b/lib/remote.exp
@@ -109,11 +109,18 @@ proc close_wait_program { program_id pid {wres_varname ""} } {
# Reap it.
set res [catch "wait -i $program_id" wres]
- if {$exec_pid != -1} {
+ if { $exec_pid != -1 && [llength $pid] == 1 } {
# 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"
+ #
+ # Do this if the PID list only has a single entry however, as
+ # otherwise `wait' will have returned right away regardless of
+ # whether any process of the pipeline has exited.
+ #
+ # 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
@@ -239,6 +246,12 @@ proc local_exec { commandline inp outp timeout } {
}
set r2 [close_wait_program $spawn_id $pid wres]
if { $id > 0 } {
+ if { $pid > 0 } {
+ # If timed-out, don't wait for all the processes associated
+ # with the pipeline to terminate as a stuck one would cause
+ # us to hang.
+ catch {fconfigure $id -blocking false}
+ }
set r2 [catch "close $id" res]
} else {
verbose "waitres is $wres" 2
@@ -384,6 +397,12 @@ proc standard_close { host } {
close_wait_program $shell_id $pid
if {[info exists oid]} {
+ if { $pid > 0 } {
+ # Don't wait for all the processes associated with the
+ # pipeline to terminate as a stuck one would cause us
+ # to hang.
+ catch {fconfigure $oid -blocking false}
+ }
catch "close $oid"
}