X Tutup
The Wayback Machine - https://web.archive.org/web/20260215123302/https://github.com/python/cpython/pull/22970
Skip to content

bpo-42146: Unify cleanup in subprocess_fork_exec()#22970

Merged
gpshead merged 4 commits intopython:masterfrom
izbyshev:bpo-42146-subprocess-cleanup-refactor
Nov 1, 2020
Merged

bpo-42146: Unify cleanup in subprocess_fork_exec()#22970
gpshead merged 4 commits intopython:masterfrom
izbyshev:bpo-42146-subprocess-cleanup-refactor

Conversation

@izbyshev
Copy link
Contributor

@izbyshev izbyshev commented Oct 25, 2020

Also ignore errors from _enable_gc():

  • They are always suppressed by the current code due to a bug.
  • _enable_gc() is only used if preexec_fn != None, which is unsafe.
  • We don't have a good way to handle errors in case we successfully
    created a child process.

https://bugs.python.org/issue42146

@izbyshev izbyshev force-pushed the bpo-42146-subprocess-cleanup-refactor branch from 10b8bc6 to e41da1d Compare October 25, 2020 14:41
@gpshead gpshead self-assigned this Oct 25, 2020
Also ignore errors from _enable_gc():
* They are always suppressed by the current code due to a bug.
* _enable_gc() is only used if `preexec_fn != None`, which is unsafe.
* We don't have a good way to handle errors in case we successfully
  created a child process.
@izbyshev izbyshev force-pushed the bpo-42146-subprocess-cleanup-refactor branch from e41da1d to 89143b4 Compare October 26, 2020 07:22
@izbyshev izbyshev marked this pull request as ready for review October 26, 2020 07:24
@izbyshev izbyshev requested a review from gpshead as a code owner October 26, 2020 07:24
Code defensively and also check `pid == -1` when setting the exception as that is the condition we return NULL on to let Python know there was an exception.

In theory they are the same.  But that depends on `fork()` or `vfork()` behaving as documented and setting errno properly (likely true... but if not we still want an error).  This also defends against future bugs if the above code were refactored wrong.
This at least lets the user know that something serious has gone wrong.
@gpshead gpshead merged commit d3b4e06 into python:master Nov 1, 2020
@izbyshev izbyshev deleted the bpo-42146-subprocess-cleanup-refactor branch January 21, 2021 18:31
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 13, 2021
* bpo-42146: Unify cleanup in subprocess_fork_exec()

Also ignore errors from _enable_gc():
* They are always suppressed by the current code due to a bug.
* _enable_gc() is only used if `preexec_fn != None`, which is unsafe.
* We don't have a good way to handle errors in case we successfully
  created a child process.

Co-authored-by: Gregory P. Smith <greg@krypto.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

X Tutup