From b393de052f9c0cb5fc18cdbcacc4b23d89f85f32 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 1 Jun 2012 23:17:48 +0200 Subject: [PATCH] Subprocess now only yields stdout/stderr if you're listening --- lib/vagrant/util/subprocess.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/vagrant/util/subprocess.rb b/lib/vagrant/util/subprocess.rb index 6f3b70ad6..0eaa6ba47 100644 --- a/lib/vagrant/util/subprocess.rb +++ b/lib/vagrant/util/subprocess.rb @@ -46,9 +46,10 @@ module Vagrant # Let's get some more useful booleans that we access a lot so # we're not constantly calling an `include` check - notify_stderr = notify.include?(:stderr) + notify_table = {} + notify_table[:stderr] = notify.include?(:stderr) + notify_table[:stdout] = notify.include?(:stdout) notify_stdin = notify.include?(:stdin) - notify_stdout = notify.include?(:stdout) # Build the ChildProcess @logger.info("Starting process: #{@command.inspect}") @@ -107,7 +108,7 @@ module Vagrant raise TimeoutExceeded, process.pid if timeout && (Time.now.to_i - start_time) > timeout # Check the readers to see if they're ready - if !readers.empty? + if readers && !readers.empty? readers.each do |r| # Read from the IO object data = read_io(r) @@ -119,7 +120,7 @@ module Vagrant @logger.debug("#{io_name}: #{data}") io_data[io_name] += data - yield io_name, data if block_given? + yield io_name, data if block_given? && notify_table[io_name] end end