[issue17131] subprocess.Popen.terminate can raise exception on Posix
Martin Panter
report at bugs.python.org
Sun Jul 20 04:42:50 CEST 2014
Martin Panter added the comment:
For Posix (dunno about Windows), calling terminate or kill at the OS level after a poll or wait has already succeeded is a bad idea, because the PID may have been recycled. It is essentially operating on a released resource, similar to calling “os.close” on a closed FD, or freeing unallocated memory.
There is a way to know if the PID is still valid though. Just make sure that successful poll and wait calls invalidate the PID. Then calling terminate or kill, or any other operation that requires the PID, would no longer be valid (or could do nothing if that is more appropriate). Similar to the behaviour of file objects after they are closed: subsequent close calls do nothing; other operations raise an exception.
----------
nosy: +vadmium
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17131>
_______________________________________
More information about the Python-bugs-list
mailing list