Skip to content

Commit 0187a7e

Browse files
gh-112800: Ignore PermissionError on SubprocessTransport.close() in asyncio (#112803)
In case the spawned process is setuid, we may not be able to send signals to it, in which case our .kill() call will raise PermissionError. Ignore that in order to avoid .close() raising an exception. Hopefully the process will exit as a result of receiving EOF on its stdin.
1 parent ca71987 commit 0187a7e

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

Lib/asyncio/base_subprocess.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ def close(self):
115115

116116
try:
117117
self._proc.kill()
118-
except ProcessLookupError:
118+
except (ProcessLookupError, PermissionError):
119+
# the process may have already exited or may be running setuid
119120
pass
120121

121122
# Don't clear the _proc reference yet: _post_init() may still run
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix :mod:`asyncio` ``SubprocessTransport.close()`` not to throw
2+
``PermissionError`` when used with setuid executables.

0 commit comments

Comments
 (0)