module SimpleCov::ProcessForkHook

def _fork

def _fork
  active = defined?(SimpleCov) && Coverage.running?
  # Assign the next serial in the PARENT, before the fork, so the child
  # inherits its own stable ordinal via copy-on-write. The default
  # at_fork uses it (instead of the child pid) to name the subprocess's
  # result, keeping that name identical across runs. See issue #1171.
  SimpleCov.next_subprocess_serial! if active
  pid = super
  if pid.zero? && active
    # Mark the child here, independent of whatever custom at_fork block
    # the user installed, so `final_result_process?` can keep forked
    # workers from each producing the final report. See issue #1171.
    SimpleCov.mark_forked_subprocess!
    # Without this, a child forked under Minitest autorun measures
    # coverage and then silently discards it: every inherited exit
    # route is dead in the child (see the method's comment). A custom
    # at_fork runs afterwards and can still override. See issue #1227.
    SimpleCov.reset_inherited_at_exit_state!
    SimpleCov.at_fork.call(::Process.pid)
  end
  pid
end