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-18 11:18:36 -0800
commit502f3c081317cf69c21f94965a647f5c05923a09 (patch)
treeead5db6edac08d789e7ab102ca1fb18b0c6ea3e7
parentf09d8a9230550efe459a407e60cb6ccbc48d3f4f (diff)
downloadmixlib-shellout-502f3c081317cf69c21f94965a647f5c05923a09.tar.gz
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.
-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 1bc8b13..1612b09 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