Subprocess now only yields stdout/stderr if you're listening

This commit is contained in:
Mitchell Hashimoto 2012-06-01 23:17:48 +02:00
parent 2441961a34
commit b393de052f
1 changed files with 5 additions and 4 deletions

View File

@ -46,9 +46,10 @@ module Vagrant
# Let's get some more useful booleans that we access a lot so # Let's get some more useful booleans that we access a lot so
# we're not constantly calling an `include` check # 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_stdin = notify.include?(:stdin)
notify_stdout = notify.include?(:stdout)
# Build the ChildProcess # Build the ChildProcess
@logger.info("Starting process: #{@command.inspect}") @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 raise TimeoutExceeded, process.pid if timeout && (Time.now.to_i - start_time) > timeout
# Check the readers to see if they're ready # Check the readers to see if they're ready
if !readers.empty? if readers && !readers.empty?
readers.each do |r| readers.each do |r|
# Read from the IO object # Read from the IO object
data = read_io(r) data = read_io(r)
@ -119,7 +120,7 @@ module Vagrant
@logger.debug("#{io_name}: #{data}") @logger.debug("#{io_name}: #{data}")
io_data[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
end end