Eryk Sun <eryk...@gmail.com> added the comment:

> I don't understand why any patch for CPython is needed at all.

If and operation on self._handle fails as an invalid handle (due to an 
underlying STATUS_INVALID_HANDLE or STATUS_OBJECT_TYPE_MISMATCH), then call 
self._handle.Detach() and re-raise the exception.

It wouldn't hurt to also address the case in which coincidentally the handle 
value currently references another process. When the process is spawned, save 
the (process_id, creation_time) via GetProcessId() and GetProcessTimes(). 
Implement a function that validates these values before calling 
WaitForSingleObject(), GetExitCodeProcess(), or TerminateProcess(). If 
validation fails, call self._handle.Detach() and raise OSError.

----------
components: +Windows
nosy: +paul.moore, steve.dower, tim.golden, zach.ware
stage: needs patch -> 
type: behavior -> enhancement
versions: +Python 3.10, Python 3.9 -Python 2.7, Python 3.6, Python 3.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue36067>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to