Skip to content

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

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

  1. 3.1
    • Process._fork is 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, and IO.popen(“-”). Application monitoring libraries can overwrite this method to hook fork events. [Feature #17795]

See also .exit! .fork .exit .getpgid also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2