From 5a3c00aeb7ca928bf4d26f8148b408028a607798 Mon Sep 17 00:00:00 2001 From: Theodore Nordsieck Date: Tue, 17 Sep 2013 09:21:33 -0700 Subject: Enabled shell command timeout on windows. --- lib/ohai/mixin/command.rb | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/lib/ohai/mixin/command.rb b/lib/ohai/mixin/command.rb index f9227d20..e80b6b10 100644 --- a/lib/ohai/mixin/command.rb +++ b/lib/ohai/mixin/command.rb @@ -103,22 +103,12 @@ module Ohai end def run_command_windows(command, timeout) - if timeout - begin - m = Mixlib::ShellOut.new(command) - m.run_command - [m.status, m.stdout, m.stderr] - rescue SystemExit => e - raise - rescue Timeout::Error => e - Ohai::Log.error("#{command} exceeded timeout #{timeout}") - raise(e) - end - else - m = Mixlib::ShellOut.new(command) - m.run_command - [m.status, m.stdout, m.stderr] - end + shellout_opts = {} + shellout_opts[:timeout] = timeout if timeout + + m = Mixlib::ShellOut.new(command, shellout_opts) + m.run_command + [m.status, m.stdout, m.stderr] end if RUBY_PLATFORM =~ /mswin|mingw32|windows/ -- cgit v1.2.1