Sha256: b9435e91390bd43f879d945b134fe4fda9c6f4258b1d7ec20b79404aee5e01dd

Contents?: true

Size: 882 Bytes

Versions: 8

Compression:

Stored size: 882 Bytes

Contents

module ::Kernel
  def fork_with_zk_hooks(&block)
    if block
      new_block = proc do
        ::ZK::ForkHook.fire_after_child_hooks!
        block.call
      end

      ::ZK::ForkHook.fire_prepare_hooks!
      fork_without_zk_hooks(&new_block).tap do
        ::ZK::ForkHook.fire_after_parent_hooks!
      end
    else
      ::ZK::ForkHook.fire_prepare_hooks!
      if pid = fork_without_zk_hooks
        ::ZK::ForkHook.fire_after_parent_hooks!
        # we're in the parent
        return pid
      else
        # we're in the child
        ::ZK::ForkHook.fire_after_child_hooks!
        return nil
      end
    end
  end
  module_function :fork_with_zk_hooks

  if defined?(fork_without_zk_hooks)
    remove_method :fork
    alias fork fork_without_zk_hooks
    remove_method :fork_without_zk_hooks
  end

  alias fork_without_zk_hooks fork
  alias fork fork_with_zk_hooks
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
zk-1.6.3 lib/zk/install_fork_hooks.rb
zk-1.6.2 lib/zk/install_fork_hooks.rb
zk-1.6.1 lib/zk/install_fork_hooks.rb
zk-1.6.0 lib/zk/install_fork_hooks.rb
zk-1.5.3 lib/zk/install_fork_hooks.rb
zk-1.5.2 lib/zk/install_fork_hooks.rb
zk-1.5.1 lib/zk/install_fork_hooks.rb
zk-1.5.0 lib/zk/install_fork_hooks.rb