summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2018-07-06 21:35:29 +1000
committerBen Elliston <bje@gnu.org>2018-07-06 21:35:29 +1000
commitb4e61f85ae26d215e8ad5d6e9fcda6c0745096a1 (patch)
tree12fcf57ac8f9aff1e468eacb3b1106915bf4da25
parentfb6ef60aa1dc724cc749d1193f17fc258a022fd9 (diff)
downloaddejagnu-b4e61f85ae26d215e8ad5d6e9fcda6c0745096a1.tar.gz
dejagnu-b4e61f85ae26d215e8ad5d6e9fcda6c0745096a1.tar.bz2
dejagnu-b4e61f85ae26d215e8ad5d6e9fcda6c0745096a1.zip
* lib/remote.exp (close_wait_program): Use separate kill command
for each pid. Signed-off-by: Ben Elliston <bje@gnu.org>
-rw-r--r--ChangeLog5
-rw-r--r--lib/remote.exp25
2 files changed, 22 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index a188140..679f997 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2018-07-06 Richard Biener <rguenther@suse.de>
+
+ * lib/remote.exp (close_wait_program): Use separate kill command
+ for each pid.
+
2017-10-16 Ben Elliston <bje@gnu.org>
* NEWS: Start a new section for the next release.
diff --git a/lib/remote.exp b/lib/remote.exp
index 4dd6a8a..3d5d176 100644
--- a/lib/remote.exp
+++ b/lib/remote.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 1992-2016 Free Software Foundation, Inc.
+# Copyright (C) 1992-2018 Free Software Foundation, Inc.
#
# This file is part of DejaGnu.
#
@@ -70,13 +70,16 @@ proc close_wait_program { program_id pid {wres_varname ""} } {
# Tcl has no kill primitive, so we have to execute an external
# command in order to kill the process.
verbose "doing kill, pid is $pid"
- # Prepend "-" to generate the "process group ID" needed by
- # kill.
- set pgid "-$pid"
# Send SIGINT to give the program a better chance to interrupt
# whatever it might be doing and react to stdin closing.
# eg, in case of GDB, this should get it back to the prompt.
- exec sh -c "exec > /dev/null 2>&1 && (kill -2 $pgid || kill -2 $pid)"
+ # Do so separately for each PID in the list to avoid differences
+ # in return value behavior for kill between shells
+ foreach spid $pid {
+ # Prepend "-" to generate the "process group ID" needed by
+ # kill.
+ exec sh -c "exec > /dev/null 2>&1 && (kill -2 -$spid || kill -2 $spid)"
+ }
# If the program doesn't exit gracefully when stdin closes,
# we'll need to kill it. But only do this after 'wait'ing a
@@ -86,9 +89,15 @@ proc close_wait_program { program_id pid {wres_varname ""} } {
# PID reuse race.
set secs 5
set sh_cmd "exec > /dev/null 2>&1"
- append sh_cmd " && sleep $secs && (kill -15 $pgid || kill -15 $pid)"
- append sh_cmd " && sleep $secs && (kill -9 $pgid || kill -9 $pid)"
- append sh_cmd " && sleep $secs"
+ append sh_cmd " && sleep $secs && ("
+ foreach spid $pid {
+ append sh_cmd "(kill -15 -$spid || kill -15 $spid);"
+ }
+ append sh_cmd ") && sleep $secs && ("
+ foreach spid $pid {
+ append sh_cmd "(kill -9 -$spid || kill -9 $spid);"
+ }
+ append sh_cmd ") && sleep $secs"
set exec_pid [exec sh -c "$sh_cmd" &]
}
verbose "pid is $pid"