[issue40550] Popen.terminate fails with ProcessLookupError under certain conditions

Filipe Laíns report at bugs.python.org
Fri May 8 17:16:48 EDT 2020


Filipe Laíns <filipe.lains at gmail.com> added the comment:

This is a simple time-of-check - time-of-action issue, which is why I suggested that it shouldn't be fixed. I was not aware send_signal did have this check, which tells us it is supposed to be suported(?). Anyway, to fix it we need to catch the exception and check for errno == 3 so that we can ignore it.

Optimally we would want to have an atomic operation here, but no such thing exists. There is still the very faint possibility that after your process exits a new process will take its id and we kill it instead.

We should keep the returncode check and just ignore the exception when errno == 3. This is the best option.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40550>
_______________________________________


More information about the Python-bugs-list mailing list