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.
This commit is contained in:
Allison Karlitskaya 2023-12-24 01:43:39 +01:00 committed by GitHub
parent ca71987f4e
commit 0187a7e4ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View file

@ -115,7 +115,8 @@ def close(self):
try:
self._proc.kill()
except ProcessLookupError:
except (ProcessLookupError, PermissionError):
# the process may have already exited or may be running setuid
pass
# Don't clear the _proc reference yet: _post_init() may still run

View file

@ -0,0 +1,2 @@
Fix :mod:`asyncio` ``SubprocessTransport.close()`` not to throw
``PermissionError`` when used with setuid executables.