summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Mundrawala <jdmundrawala@gmail.com>2014-12-16 23:29:55 -0800
committerJay Mundrawala <jdmundrawala@gmail.com>2014-12-16 23:29:55 -0800
commit88dd26a57a20035b572bd247ef8b77e2af3ad3ef (patch)
treed4e58bedee89483b7ddd7e888b3560ea3700babb
parent77211bdafb783b9067aa1fb32cd8bfa026a9769f (diff)
downloadmixlib-shellout-jdm/win-kill-proc.tar.gz
On windows, send sigkill to process if it exceeds its alloted timejdm/win-kill-proc
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.
-rw-r--r--lib/mixlib/shellout/windows.rb6
1 files changed, 6 insertions, 0 deletions
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