def pending_output(chunk_len = 49152)
      # Returns nil if there is no pending output.
      return unless pending_output?

      pending = String.new
      while chunk = @output.read_nonblock(chunk_len)
        pending << chunk
      end
      pending.force_encoding('UTF-8')
    rescue IO::WaitReadable
      pending.force_encoding('UTF-8')
    rescue
      raise Closed if READING_ON_CLOSED_END_ERRORS.any? { |exc| $!.is_a?(exc) }
    end
def pending_output(chunk_len = 49152)
      # Returns nil if there is no pending output.
      return unless pending_output?

      pending = String.new
      while chunk = @output.read_nonblock(chunk_len)
        pending << chunk
      end
      pending.force_encoding('UTF-8')
    rescue IO::WaitReadable
      pending.force_encoding('UTF-8')
    rescue
      raise Closed if READING_ON_CLOSED_END_ERRORS.any? { |exc| $!.is_a?(exc) }
    end
Gets the pending output of the process.

 The pending output is read in an non blocking way by chunks, in the size
 of +chunk_len+. By default, +chunk_len+ is 49152 bytes.

 Returns +nil+, if there is no pending output at the moment. Otherwise,
 returns the output that hasn't been read since the last invocation.

 Raises Errno:EIO on closed output stream. This can happen if the
 underlying process exits.