class RSpec::Core::Bisect::Channel

@private
parent.
set to ensure binary data is able to pass from child to
parent process. Where supported, encoding is explicitly
Wraps a pipe to support sending objects between a child and

def close

def close
  @read_io.close
  @write_io.close
end

def initialize

def initialize
  @read_io, @write_io = IO.pipe
  if defined?(MARSHAL_DUMP_ENCODING) && IO.method_defined?(:set_encoding)
    # Ensure the pipe can send any content produced by Marshal.dump
    @write_io.set_encoding MARSHAL_DUMP_ENCODING
  end
end

def receive

rubocop:disable Security/MarshalLoad
def receive
  packet_size = Integer(@read_io.gets)
  Marshal.load(@read_io.read(packet_size))
end

def send(message)

def send(message)
  packet = Marshal.dump(message)
  @write_io.write("#{packet.bytesize}\n#{packet}")
end