From 88dd26a57a20035b572bd247ef8b77e2af3ad3ef Mon Sep 17 00:00:00 2001 From: Jay Mundrawala Date: Tue, 16 Dec 2014 23:29:55 -0800 Subject: On windows, send sigkill to process if it exceeds its alloted time Timeouts did not work correctly on windows because we do not kill or abandon the process. What was happening was a timeout condition was getting correctly detected, and an exception was being raised. However, before the exception could propogate, whatever the process was writing was fully read until it closed its FD. --- lib/mixlib/shellout/windows.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/mixlib/shellout/windows.rb b/lib/mixlib/shellout/windows.rb index 137aaa9..bf74653 100644 --- a/lib/mixlib/shellout/windows.rb +++ b/lib/mixlib/shellout/windows.rb @@ -111,6 +111,12 @@ module Mixlib when WAIT_TIMEOUT # Kill the process if (Time.now - start_wait) > timeout + begin + Process.kill(:KILL, process.process_id) + rescue Errno::EIO + logger.warn("Failed to kill timed out process #{process.process_id}") if logger + end + raise Mixlib::ShellOut::CommandTimeout, "command timed out:\n#{format_for_exception}" end -- cgit v1.2.1