def wait(flags=0)
      config.ui.logger.debug { "wait" }
      config.ui.logger.debug { "forks(#{@forks.inspect})" }

      return nil if @forks.count <= 0

      pid, status = (Process.wait2(-1, Process::WUNTRACED) rescue nil)

      if !pid.nil? && !status.nil? && !(fork = @forks.select{ |f| f[:pid] == pid }.first).nil?
        data = nil
        begin
          data = Marshal.load(Zlib::Inflate.inflate(Base64.decode64(fork[:reader].read).to_s))
        rescue Zlib::BufError
          config.ui.logger.fatal { "Encountered Zlib::BufError when reading child pipe." }
        end
        config.ui.logger.debug { "read(#{data.inspect})" }

        data = process_data(data)
        !data.nil? and @results.push(data)

        fork[:reader].close
        fork[:writer].close

        @forks -= [fork]
        return [pid, status, data]
      end
      nil
    end
def wait(flags=0)
      config.ui.logger.debug { "wait" }
      config.ui.logger.debug { "forks(#{@forks.inspect})" }

      return nil if @forks.count <= 0

      pid, status = (Process.wait2(-1, Process::WUNTRACED) rescue nil)

      if !pid.nil? && !status.nil? && !(fork = @forks.select{ |f| f[:pid] == pid }.first).nil?
        data = nil
        begin
          data = Marshal.load(Zlib::Inflate.inflate(Base64.decode64(fork[:reader].read).to_s))
        rescue Zlib::BufError
          config.ui.logger.fatal { "Encountered Zlib::BufError when reading child pipe." }
        end
        config.ui.logger.debug { "read(#{data.inspect})" }

        data = process_data(data)
        !data.nil? and @results.push(data)

        fork[:reader].close
        fork[:writer].close

        @forks -= [fork]
        return [pid, status, data]
      end
      nil
    end
Wait for a single fork to finish.

 If a fork successfully finishes, it's return value from the *process*
 block is stored into the main result set.

 @return [Array<pid, status, data>] An array containing the pid,
   status and data returned from the process block.  If wait2() fails nil
   is returned.