Reliably kill test processes

It seems command -v also includes built-ins so checking for kill
is useless because it finds the built-in and those machines or
environments that have no /bin/kill fail at the check stage.
Oh and then TCL exec doesn't spawn a shell.

After reading way too many TCL websites, I believe this should
fix the problem. TCL quoting is... different to say the least but
it works reliably here. The script now even picked up a typo elsewhere
which was nice.

This change should stop the intermittent FTBFS bugs from the Debian
pbuilders, I hope! You'd think kill $var wouldn't be this difficult.
This commit is contained in:
Craig Small
2014-07-01 18:51:21 +10:00
parent 96c330e3b3
commit cacba5613e
3 changed files with 17 additions and 18 deletions

View File

@@ -7,6 +7,13 @@ set usage_help "\\s*-h, --help\\s+display this help and exit\\s+"
set usage_version "\\s*-V, --version\\s+output version information and exit\\s+"
set usage_man "\\s*For more details see \\S+\\."
proc kill_process pid {
set cmdline "kill $pid"
if { [catch { exec /bin/sh -c $cmdline } msg]} {
warning "Could not kill process: $msg\n"
}
}
proc procps_v_version { tool } {
global topdir
set toolpath ${topdir}${tool}
@@ -131,3 +138,11 @@ proc make_testproc { } {
set testproc1_pid [ exec $testproc_path $sleep_time & ]
set testproc2_pid [ exec $testproc_path $sleep_time & ]
}
proc kill_testproc { } {
global testproc_path testproc1_pid testproc2_pid
kill_process $testproc1_pid
kill_process $testproc2_pid
file delete $testproc_path
}