Method: Chef::ShellOut::Windows#run_command
- Defined in:
- lib/chef/shell_out/windows.rb
#run_command ⇒ Object
– Missing lots of features from the UNIX version, such as environment, cwd, etc.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/chef/shell_out/windows.rb', line 33 def run_command # win32 open4 is really just open3. Open3.popen3(@command) do |stdin,stdout,stderr| @finished_stdout = false @finished_stderr = false stdin.close stdout.sync = true stderr.sync = true # TBH, I really don't know what this will do when it times out. # However, I'm powerless to make windows have non-blocking IO, so # thread party it is. Timeout.timeout(timeout) do out_reader = Thread.new do loop do read_stdout(stdout) break if @finished_stdout end end err_reader = Thread.new do loop do read_stderr(stderr) break if @finished_stderr end end out_reader.join err_reader.join end end @status = $? self rescue Timeout::Error raise Chef::Exceptions::CommandTimeout, "command timed out:\n#{format_for_exception}" end |