End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
class method · added in Ruby 3.1
Process._fork
Process._fork → integer
process.c
View on GitHub ↗
VALUE
rb_proc__fork(VALUE _obj)
{
rb_pid_t pid = rb_fork_ruby(NULL);
if (pid == -1) {
rb_sys_fail("fork(2)");
}
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.
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]
-