bpo-40550: Fix time-of-check/time-of-action issue in subprocess.Popen.send_signal. by FFY00 · Pull Request #20010 · python/cpython

ZackerySpytz

remilapeyre

@FFY00

Signed-off-by: Filipe Laíns <lains@archlinux.org>

gpshead

@gpshead

The ProcessLookupError already means errno == ESRCH.

@gpshead gpshead changed the title bpo-40550: fix time-of-check/time-of-action issue in multiprocessing bpo-40550: Fix time-of-check/time-of-action issue in subprocess.Popen.send_signal.

Nov 21, 2020

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request

Nov 21, 2020
….send_signal. (pythonGH-20010)

send_signal() now swallows the exception if the process it thought was still alive winds up not to exist anymore (always a plausible race condition despite the checks).

Co-authored-by: Gregory P. Smith <greg@krypto.org>
(cherry picked from commit 01a202a)

Co-authored-by: Filipe Laíns <lains@archlinux.org>

miss-islington added a commit that referenced this pull request

Nov 21, 2020
….send_signal. (GH-20010)

send_signal() now swallows the exception if the process it thought was still alive winds up not to exist anymore (always a plausible race condition despite the checks).

Co-authored-by: Gregory P. Smith <greg@krypto.org>
(cherry picked from commit 01a202a)

Co-authored-by: Filipe Laíns <lains@archlinux.org>

adorilson pushed a commit to adorilson/cpython that referenced this pull request

Mar 13, 2021
….send_signal. (pythonGH-20010)

send_signal() now swallows the exception if the process it thought was still alive winds up not to exist anymore (always a plausible race condition despite the checks).

Co-authored-by: Gregory P. Smith <greg@krypto.org>

gschaffner added a commit to gschaffner/cpython that referenced this pull request

Nov 20, 2024
Note that we call Popen.poll/wait in the event loop thread to avoid
Popen's thread-unsafety. Without this workaround, when testing
_ThreadedChildWatcher with the reproducer shared in the linked issue on my
machine:
* Case 1 of the known race condition ignored in pythonGH-20010 is met (and an
  unsafe kill call is issued) about 1 in 10 times.
* The race condition pythonGH-127050 is met (causing _process_exited's assert
  returncode is not None to raise) about 1 in 30 times.