diff options
author | Victor Stinner <vstinner@python.org> | 2020-06-02 13:51:37 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-02 13:51:37 (GMT) |
commit | 26881c8fae3b67db3a01d335d3ae7356a29b433e (patch) | |
tree | 8cf867af2cd74581dc037a70e0549087d7e39fd3 /Python/ceval.c | |
parent | 297257f7bc198e2dc8e0866b539c73ff1a5cc588 (diff) | |
download | cpython-26881c8fae3b67db3a01d335d3ae7356a29b433e.zip cpython-26881c8fae3b67db3a01d335d3ae7356a29b433e.tar.gz cpython-26881c8fae3b67db3a01d335d3ae7356a29b433e.tar.bz2 |
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().
Diffstat (limited to 'Python/ceval.c')
-rw-r--r-- | Python/ceval.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 01dd361..5edcfe3 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -433,11 +433,9 @@ PyEval_ReleaseThread(PyThreadState *tstate) #ifdef HAVE_FORK /* This function is called from PyOS_AfterFork_Child to destroy all threads - * which are not running in the child process, and clear internal locks - * which might be held by those threads. - */ - -void + which are not running in the child process, and clear internal locks + which might be held by those threads. */ +PyStatus _PyEval_ReInitThreads(_PyRuntimeState *runtime) { PyThreadState *tstate = _PyRuntimeState_GetThreadState(runtime); @@ -449,7 +447,7 @@ _PyEval_ReInitThreads(_PyRuntimeState *runtime) struct _gil_runtime_state *gil = &runtime->ceval.gil; #endif if (!gil_created(gil)) { - return; + return _PyStatus_OK(); } recreate_gil(gil); @@ -457,11 +455,12 @@ _PyEval_ReInitThreads(_PyRuntimeState *runtime) struct _pending_calls *pending = &tstate->interp->ceval.pending; if (_PyThread_at_fork_reinit(&pending->lock) < 0) { - Py_FatalError("Can't initialize threads for pending calls"); + return _PyStatus_ERR("Can't reinitialize pending calls lock"); } /* Destroy all threads except the current one */ _PyThreadState_DeleteExcept(runtime, tstate); + return _PyStatus_OK(); } #endif |