mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
PyOS_AfterFork_Child() uses PyStatus (GH-20596)
PyOS_AfterFork_Child() helper functions now return a PyStatus: PyOS_AfterFork_Child() is now responsible to handle errors. * Move _PySignal_AfterFork() to the internal C API * Add #ifdef HAVE_FORK on _PyGILState_Reinit(), _PySignal_AfterFork() and _PyInterpreterState_DeleteExceptMain().
This commit is contained in:
parent
297257f7bc
commit
26881c8fae
10 changed files with 84 additions and 50 deletions
|
@ -34,6 +34,7 @@
|
|||
|
||||
#include "pycore_ceval.h" // _PyEval_ReInitThreads()
|
||||
#include "pycore_import.h" // _PyImport_ReInitLock()
|
||||
#include "pycore_initconfig.h" // _PyStatus_EXCEPTION()
|
||||
#include "pycore_pystate.h" // _PyInterpreterState_GET()
|
||||
#include "structmember.h" // PyMemberDef
|
||||
#ifndef MS_WINDOWS
|
||||
|
@ -461,15 +462,41 @@ PyOS_AfterFork_Parent(void)
|
|||
void
|
||||
PyOS_AfterFork_Child(void)
|
||||
{
|
||||
PyStatus status;
|
||||
_PyRuntimeState *runtime = &_PyRuntime;
|
||||
_PyGILState_Reinit(runtime);
|
||||
_PyEval_ReInitThreads(runtime);
|
||||
_PyImport_ReInitLock();
|
||||
|
||||
status = _PyGILState_Reinit(runtime);
|
||||
if (_PyStatus_EXCEPTION(status)) {
|
||||
goto fatal_error;
|
||||
}
|
||||
|
||||
status = _PyEval_ReInitThreads(runtime);
|
||||
if (_PyStatus_EXCEPTION(status)) {
|
||||
goto fatal_error;
|
||||
}
|
||||
|
||||
status = _PyImport_ReInitLock();
|
||||
if (_PyStatus_EXCEPTION(status)) {
|
||||
goto fatal_error;
|
||||
}
|
||||
|
||||
_PySignal_AfterFork();
|
||||
_PyRuntimeState_ReInitThreads(runtime);
|
||||
_PyInterpreterState_DeleteExceptMain(runtime);
|
||||
|
||||
status = _PyRuntimeState_ReInitThreads(runtime);
|
||||
if (_PyStatus_EXCEPTION(status)) {
|
||||
goto fatal_error;
|
||||
}
|
||||
|
||||
status = _PyInterpreterState_DeleteExceptMain(runtime);
|
||||
if (_PyStatus_EXCEPTION(status)) {
|
||||
goto fatal_error;
|
||||
}
|
||||
|
||||
run_at_forkers(_PyInterpreterState_GET()->after_forkers_child, 0);
|
||||
return;
|
||||
|
||||
fatal_error:
|
||||
Py_ExitStatusException(status);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue