summaryrefslogtreecommitdiffstats
path: root/Lib/subprocess.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2020-11-21 09:46:21 (GMT)
committerGitHub <noreply@github.com>2020-11-21 09:46:21 (GMT)
commit713b4bbd97392acc492a4fefb2d07ae61fb7b75d (patch)
tree30d3c2270e96cc908c5c9cf1a9d3da01871bc87e /Lib/subprocess.py
parentc1bbca5b004b3f74d240ef8a76ff445cc1a27efb (diff)
downloadcpython-713b4bbd97392acc492a4fefb2d07ae61fb7b75d.zip
cpython-713b4bbd97392acc492a4fefb2d07ae61fb7b75d.tar.gz
cpython-713b4bbd97392acc492a4fefb2d07ae61fb7b75d.tar.bz2
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> (cherry picked from commit 01a202ab6b0ded546e47073db6498262086c52e9) Co-authored-by: Filipe LaĆ­ns <lains@archlinux.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 13600c2..f1d829a 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -2061,7 +2061,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