diff options
author | Matt Wrock <matt@mattwrock.com> | 2015-10-20 12:53:19 -0700 |
---|---|---|
committer | Matt Wrock <matt@mattwrock.com> | 2015-10-20 12:53:19 -0700 |
commit | 8396810eac9c733437118243be87fae40f11ecc4 (patch) | |
tree | 9eb6bf6be5c4a01cf6e78c00a2059495598e952e /lib | |
parent | 8e3a0d76591696420db87dab9019d295f15a3eb7 (diff) | |
download | mixlib-shellout-8396810eac9c733437118243be87fae40f11ecc4.tar.gz |
improve the test to more accurately detrermine if child process is killed
Diffstat (limited to 'lib')
-rw-r--r-- | lib/mixlib/shellout/windows.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/mixlib/shellout/windows.rb b/lib/mixlib/shellout/windows.rb index 5bca289..571baa6 100644 --- a/lib/mixlib/shellout/windows.rb +++ b/lib/mixlib/shellout/windows.rb @@ -77,8 +77,8 @@ module Mixlib # # Start the process # - logger.debug(Utils.format_process(process, app_name, command_line, timeout)) if logger process = Process.create(create_process_args) + logger.debug(Utils.format_process(process, app_name, command_line, timeout)) if logger begin # Start pushing data into input stdin_write << input if input @@ -322,7 +322,7 @@ module Mixlib end def self.kill_process_tree(pid, wmi, logger) - wmi.query("select ProcessID, Name from Win32_Process where ParentProcessID=#{pid}").each do |instance| + wmi.query("select * from Win32_Process where ParentProcessID=#{pid}").each do |instance| child_pid = instance.wmi_ole_object.processid kill_process_tree(child_pid, wmi, logger) begin @@ -330,7 +330,7 @@ module Mixlib "killing child process #{child_pid}::", "#{instance.wmi_ole_object.Name} of parent #{pid}" ].join) if logger - Process.kill(:KILL, child_pid) + kill_process(instance) rescue Errno::EIO, SystemCallError logger.debug([ "Failed to kill child process #{child_pid}::", @@ -340,6 +340,10 @@ module Mixlib end end + def self.kill_process(instance) + Process.kill(:KILL, instance.wmi_ole_object.processid) + end + def self.format_process(process, app_name, command_line, timeout) msg = [] msg << "ProcessId: #{process.process_id}" |