def run_command
Open3.popen3(@command) do |stdin,stdout,stderr|
@finished_stdout = false
@finished_stderr = false
stdin.close
stdout.sync = true
stderr.sync = true
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
@status = $?
end
end
self
rescue Timeout::Error
raise Chef::Exceptions::CommandTimeout, "command timed out:\n#{format_for_exception}"
end