diff options
author | Jay Mundrawala <jdmundrawala@gmail.com> | 2014-12-16 23:29:55 -0800 |
---|---|---|
committer | Jay Mundrawala <jdmundrawala@gmail.com> | 2014-12-18 11:18:36 -0800 |
commit | 502f3c081317cf69c21f94965a647f5c05923a09 (patch) | |
tree | ead5db6edac08d789e7ab102ca1fb18b0c6ea3e7 /lib/mixlib | |
parent | f09d8a9230550efe459a407e60cb6ccbc48d3f4f (diff) | |
download | mixlib-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.
Diffstat (limited to 'lib/mixlib')
-rw-r--r-- | lib/mixlib/shellout/windows.rb | 6 |
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 |