def wait
      @accumulators = {}
      waits = {}
      @buffered_echo = []

      ioes = streams.values
      ioes.each do |io|
        @accumulators[io] = []
        waits[io] = 3
      end
      begin_echoing = Time.now + (@consume_timeout || 3)

      @live_ioes = ioes.dup

      until @live_ioes.empty? do
        newpid, @process_status = Process.waitpid2(pid, Process::WNOHANG)

        unless @process_status.nil?
          consume_buffers(@live_ioes)
          break
        end

        timeout = 0

        if !@buffered_echo.nil?
          timeout = begin_echoing - Time.now
          if timeout < 0
            @shell.report ""
            @shell.report "Long running command output:"
            @shell.report @buffered_echo.join
            @buffered_echo = nil
          end
        end

        if timeout > 0
          result = IO::select(@live_ioes, [], @live_ioes, timeout)
        else
          result = IO::select(@live_ioes, [], @live_ioes, 1)
        end

        unless result.nil? #timeout
          readable, _writeable, errored = *result
          unless errored.empty?
            raise "Error on IO: #{errored.inspect}"
          end

          consume_buffers(readable)
        end
      end

      if @process_status.nil?
        newpid, @process_status = Process.waitpid2(pid)
      end

      ioes.each do |io|
        io.close
      end
      @streams = Hash[ioes.each_with_index.map{|io, index| [index + 1, @accumulators[io].join]}]
    end
def wait
      @accumulators = {}
      waits = {}
      @buffered_echo = []

      ioes = streams.values
      ioes.each do |io|
        @accumulators[io] = []
        waits[io] = 3
      end
      begin_echoing = Time.now + (@consume_timeout || 3)

      @live_ioes = ioes.dup

      until @live_ioes.empty? do
        newpid, @process_status = Process.waitpid2(pid, Process::WNOHANG)

        unless @process_status.nil?
          consume_buffers(@live_ioes)
          break
        end

        timeout = 0

        if !@buffered_echo.nil?
          timeout = begin_echoing - Time.now
          if timeout < 0
            @shell.report ""
            @shell.report "Long running command output:"
            @shell.report @buffered_echo.join
            @buffered_echo = nil
          end
        end

        if timeout > 0
          result = IO::select(@live_ioes, [], @live_ioes, timeout)
        else
          result = IO::select(@live_ioes, [], @live_ioes, 1)
        end

        unless result.nil? #timeout
          readable, _writeable, errored = *result
          unless errored.empty?
            raise "Error on IO: #{errored.inspect}"
          end

          consume_buffers(readable)
        end
      end

      if @process_status.nil?
        newpid, @process_status = Process.waitpid2(pid)
      end

      ioes.each do |io|
        io.close
      end
      @streams = Hash[ioes.each_with_index.map{|io, index| [index + 1, @accumulators[io].join]}]
    end
Waits for the process to complete. If this takes longer that
 {consume_timeout}, output on the process's streams will be output via
 {Shell#report} - very useful when compilation or network transfers are
 taking a long time.