module DEBUGGER__::ForkInterceptor

Public Instance Methods

_fork() click to toggle source
Calls superclass method
# File debug-1.7.1/lib/debug/session.rb, line 2399
def _fork
  return super unless defined?(SESSION) && SESSION.active?

  parent_hook, child_hook = __fork_setup_for_debugger

  super.tap do |pid|
    if pid != 0
      # after fork: parent
      parent_hook.call pid
    else
      # after fork: child
      child_hook.call
    end
  end
end
fork(&given_block) click to toggle source
Calls superclass method
# File debug-1.7.1/lib/debug/session.rb, line 2415
def fork(&given_block)
  return super unless defined?(SESSION) && SESSION.active?
  parent_hook, child_hook = __fork_setup_for_debugger

  if given_block
    new_block = proc {
      # after fork: child
      child_hook.call
      given_block.call
    }
    super(&new_block).tap{|pid| parent_hook.call(pid)}
  else
    super.tap do |pid|
      if pid
        # after fork: parent
        parent_hook.call pid
      else
        # after fork: child
        child_hook.call
      end
    end
  end
end