diff options
author | Tim Smith <tsmith84@gmail.com> | 2016-02-17 12:28:45 -0800 |
---|---|---|
committer | mcquin <claire@chef.io> | 2016-04-01 10:05:43 -0700 |
commit | e577c90e03951f109cad6b9cb8908281a8088748 (patch) | |
tree | 5d188f60b5a6c51131af9c3930e370838964e51b | |
parent | 4cb6ed323642fb8b59d5d22eee0b4340b9c46cca (diff) | |
download | ohai-e577c90e03951f109cad6b9cb8908281a8088748.tar.gz |
Add a 30 sec timeout when shelling out
-rw-r--r-- | lib/ohai/mixin/command.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/ohai/mixin/command.rb b/lib/ohai/mixin/command.rb index 8cfc7d10..6be29a7d 100644 --- a/lib/ohai/mixin/command.rb +++ b/lib/ohai/mixin/command.rb @@ -29,7 +29,7 @@ module Ohai module Mixin module Command def shell_out(cmd) - m = Mixlib::ShellOut.new(cmd) + m = Mixlib::ShellOut.new(cmd, :timeout => 30) begin m.run_command @@ -43,6 +43,9 @@ module Ohai rescue Errno::ENOENT => e Ohai::Log.debug("Plugin #{self.name} failed to run command #{cmd}") raise Ohai::Exceptions::Exec, e + rescue Mixlib::ShellOut::CommandTimeout => e + Ohai::Log.debug("Plugin #{self.name} timeout after 30s running command #{cmd}") + raise Ohai::Exceptions::Exec, e end end |