aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilipe Laíns <lains@archlinux.org>2020-11-21 09:22:08 +0000
committerGitHub <noreply@github.com>2020-11-21 01:22:08 -0800
commit01a202ab6b0ded546e47073db6498262086c52e9 (patch)
tree93560f437ba651e66bbed88130a2aa90a36a3be5 /Lib/subprocess.py
parentbpo-40791: Make compare_digest more constant-time. (GH-20444) (diff)
downloadcpython-01a202ab6b0ded546e47073db6498262086c52e9.tar.gz
cpython-01a202ab6b0ded546e47073db6498262086c52e9.tar.bz2
cpython-01a202ab6b0ded546e47073db6498262086c52e9.zip
bpo-40550: Fix time-of-check/time-of-action issue in subprocess.Popen.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>
Diffstat (limited to 'Lib/subprocess.py')
-rw-r--r--Lib/subprocess.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index 6a6c2fc98e8..e259dc3a8e5 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -2078,7 +2078,11 @@ class Popen(object):
# The race condition can still happen if the race condition
# described above happens between the returncode test
# and the kill() call.
- os.kill(self.pid, sig)
+ try:
+ os.kill(self.pid, sig)
+ except ProcessLookupError:
+ # Supress the race condition error; bpo-40550.
+ pass
def terminate(self):
"""Terminate the process with SIGTERM