Module: tools Branch: master Commit: fbe2ece2c2bc8cea8d543af4ccddea2d95ef2256 URL: https://gitlab.winehq.org/winehq/tools/-/commit/fbe2ece2c2bc8cea8d543af4ccdd...
Author: Francois Gouget fgouget@codeweavers.com Date: Fri Nov 18 19:40:10 2022 +0100
testbot: Put child processes in their own process group and kill the group.
Some child processes start processes of their own. In particular LibvirtTool runs SetWineLocale and Net::OpenSSH starts ssh processes behind the scenes. Those could linger when the child process times out and, in particular, the ssh processes could keep maintain network connections to the host used for ssh tunneling. So make sure that when a child process must be killed the whole subprocess tree is terminated too.
---
testbot/lib/WineTestBot/VMs.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/testbot/lib/WineTestBot/VMs.pm b/testbot/lib/WineTestBot/VMs.pm index 2f736c63..467f750b 100644 --- a/testbot/lib/WineTestBot/VMs.pm +++ b/testbot/lib/WineTestBot/VMs.pm @@ -146,6 +146,7 @@ use WineTestBot::WineTestBotObjects; our @ISA = qw(WineTestBot::WineTestBotItem);
use File::Basename; +use POSIX; # setpgid()
use ObjectModel::BackEnd; use WineTestBot::Config; @@ -328,7 +329,8 @@ sub KillChild($) { require WineTestBot::Log; WineTestBot::Log::LogMsg("Killing child ". $self->ChildPid ."\n"); - kill("TERM", $self->ChildPid); + # Kill the child process and all its descendants + kill("TERM", -$self->ChildPid); } $self->ChildDeadline(undef); $self->ChildPid(undef); @@ -483,6 +485,9 @@ sub Run($$$$$$) # Close the database connections CloseAllDBBackEnds();
+ # Put this process and all its descendants in a new process group + setpgid(0, 0); + # Wait for the parent to set $VM->ChildPid close($fd_write); sysread($fd_read, $fd_write, 1);