mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
bpo-16500: Allow registering at-fork handlers (#1715)
* bpo-16500: Allow registering at-fork handlers * Address Serhiy's comments * Add doc for new C API * Add doc for new Python-facing function * Add NEWS entry + doc nit
This commit is contained in:
parent
f931fd1c2a
commit
346cbd351e
15 changed files with 365 additions and 68 deletions
|
@ -26,6 +26,42 @@ Operating System Utilities
|
|||
one of the strings ``'<stdin>'`` or ``'???'``.
|
||||
|
||||
|
||||
.. c:function:: void PyOS_BeforeFork()
|
||||
|
||||
Function to prepare some internal state before a process fork. This
|
||||
should be called before calling :c:func:`fork` or any similar function
|
||||
that clones the current process.
|
||||
Only available on systems where :c:func:`fork` is defined.
|
||||
|
||||
.. versionadded:: 3.7
|
||||
|
||||
|
||||
.. c:function:: void PyOS_AfterFork_Parent()
|
||||
|
||||
Function to update some internal state after a process fork. This
|
||||
should be called from the parent process after calling :c:func:`fork`
|
||||
or any similar function that clones the current process, regardless
|
||||
of whether process cloning was successful.
|
||||
Only available on systems where :c:func:`fork` is defined.
|
||||
|
||||
.. versionadded:: 3.7
|
||||
|
||||
|
||||
.. c:function:: void PyOS_AfterFork_Child()
|
||||
|
||||
Function to update some internal state after a process fork. This
|
||||
should be called from the child process after calling :c:func:`fork`
|
||||
or any similar function that clones the current process.
|
||||
Only available on systems where :c:func:`fork` is defined.
|
||||
|
||||
.. versionadded:: 3.7
|
||||
|
||||
.. seealso::
|
||||
:func:`os.register_at_fork` allows registering custom Python functions
|
||||
to be called by :c:func:`PyOS_BeforeFork()`,
|
||||
:c:func:`PyOS_AfterFork_Parent` and :c:func:`PyOS_AfterFork_Child`.
|
||||
|
||||
|
||||
.. c:function:: void PyOS_AfterFork()
|
||||
|
||||
Function to update some internal state after a process fork; this should be
|
||||
|
@ -33,6 +69,9 @@ Operating System Utilities
|
|||
If a new executable is loaded into the new process, this function does not need
|
||||
to be called.
|
||||
|
||||
.. deprecated:: 3.7
|
||||
This function is superseded by :c:func:`PyOS_AfterFork_Child()`.
|
||||
|
||||
|
||||
.. c:function:: int PyOS_CheckStack()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue