Process._fork
VALUE
rb_proc__fork(VALUE _obj)
{
rb_pid_t pid = proc_fork_pid();
return PIDT2NUM(pid);
}
An internal API for fork. Do not call this method directly. Currently, this is called via Kernel#fork, Process.fork, and IO.popen with "-".
This method is not for casual code but for application monitoring libraries. You can add custom code before and after fork events by overriding this method.
Note: Process.daemon may be implemented using fork(2) BUT does not go through this method. Thus, depending on your reason to hook into this method, you may also want to hook into that one. See this issue for a more detailed discussion of this.
Ruby version changes
-
3.1
-
Process._forkis added. This is a core method for fork(2). Do not call this method directly; it is called by existing fork methods:Kernel.#fork,Process.fork, andIO.popen(“-”). Application monitoring libraries can overwrite this method to hook fork events. [Feature #17795]
-