summaryrefslogtreecommitdiffstats
path: root/Lib/subprocess.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-03-11 18:33:29 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-03-11 18:33:29 (GMT)
commitb69ef16fe63e6de91c5d659bd83d9eff67b38d98 (patch)
tree4b30e9f75998b4d12b701a5d58c7ac5beda80ce8 /Lib/subprocess.py
parent6c52c5755fb63e50364f66fd98b8096c236ae633 (diff)
parent1f9a8354002dbb29f38bfbd4273ce62e40ac80ba (diff)
downloadcpython-b69ef16fe63e6de91c5d659bd83d9eff67b38d98.zip
cpython-b69ef16fe63e6de91c5d659bd83d9eff67b38d98.tar.gz
cpython-b69ef16fe63e6de91c5d659bd83d9eff67b38d98.tar.bz2
Issue #14252: Fix subprocess.Popen.terminate() to not raise an error under Windows when the child process has already exited.
Diffstat (limited to 'Lib/subprocess.py')
-rw-r--r--Lib/subprocess.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index a0aadb9..684086b 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -1162,7 +1162,15 @@ class Popen(object):
def terminate(self):
"""Terminates the process
"""
- _subprocess.TerminateProcess(self._handle, 1)
+ try:
+ _subprocess.TerminateProcess(self._handle, 1)
+ except PermissionError:
+ # ERROR_ACCESS_DENIED (winerror 5) is received when the
+ # process already died.
+ rc = _subprocess.GetExitCodeProcess(self._handle)
+ if rc == _subprocess.STILL_ACTIVE:
+ raise
+ self.returncode = rc
kill = terminate