class Ferrum::Browser::Process

def start

def start
  # Don't do anything as browser is already running as external process.
  return if ws_url
  begin
    read_io, write_io = IO.pipe
    process_options = { in: File::NULL }
    process_options[:pgroup] = true unless Utils::Platform.windows?
    process_options[:out] = process_options[:err] = write_io
    if @command.xvfb?
      @xvfb = Xvfb.start(@command.options)
      ObjectSpace.define_finalizer(self, self.class.process_killer(@xvfb.pid))
    end
    env = Hash(@xvfb&.to_env).merge(@env)
    @pid = ::Process.spawn(env, *@command.to_a, process_options)
    ObjectSpace.define_finalizer(self, self.class.process_killer(@pid))
    parse_ws_url(read_io, @process_timeout)
    parse_json_version(ws_url)
  ensure
    close_io(read_io, write_io)
  end
end