Module: Datadog::Profiling::Ext::Forking::ProcessDaemonPatch

Defined in:
lib/datadog/profiling/ext/forking.rb

Overview

A call to Process.daemon ( rubyapi.org/3.1/o/process#method-c-daemon ) forks the current process and keeps executing code in the child process, killing off the parent, thus effectively replacing it.

This monkey patch makes the ‘Kernel#at_fork` mechanism defined above also work in this situation.

Instance Method Summary collapse

Instance Method Details

#daemon(*args) ⇒ Object



83
84
85
86
87
88
89
90
91
# File 'lib/datadog/profiling/ext/forking.rb', line 83

def daemon(*args)
  ddtrace_at_fork_blocks = Datadog::Profiling::Ext::Forking::Kernel.ddtrace_at_fork_blocks

  result = super

  ddtrace_at_fork_blocks[:child].each(&:call) if ddtrace_at_fork_blocks.key?(:child)

  result
end