Handle native exited-child errors during private cleanup
This commit is contained in:
1 parent
5c0f6a3fd3
commit
f26e868bfc
2 files changed
+31
-2
No files matched your search
@@ -241,6 +241,30 @@ def test_descendant_handles_are_owned_before_terminating_the_job():
|
||||
assert ('close', 'child') in events
|
||||
|
||||
|
||||
@pytest.mark.parametrize('error_code', [87, 5])
|
||||
def test_native_descendant_open_error_only_ignores_already_exited_process(error_code):
|
||||
# pywintypes.error derives directly from Exception, rather than OSError.
|
||||
class NativeError(Exception):
|
||||
pass
|
||||
|
||||
error = NativeError(error_code, 'OpenProcess', 'native process open failed')
|
||||
api, events, _state, *_ = native_api()
|
||||
api.job.JobObjectBasicProcessIdList = 3
|
||||
query = api.job.QueryInformationJobObject
|
||||
api.job.QueryInformationJobObject = lambda job, kind: [43] if kind == 3 else query(job, kind)
|
||||
def open_child(*_args):
|
||||
raise error
|
||||
api.open_process = open_child
|
||||
process = api.create_process(('python.exe',), 'winsta0\\private', None, None)
|
||||
if error_code == 87:
|
||||
process._remember_descendants()
|
||||
assert process._descendant_handles == []
|
||||
else:
|
||||
with pytest.raises(NativeError) as caught:
|
||||
process._remember_descendants()
|
||||
assert caught.value is error
|
||||
|
||||
|
||||
def test_unconfirmed_descendant_exit_retains_handle_for_cleanup_retry():
|
||||
api, events, state, *_ = native_api()
|
||||
process = api.create_process(('python.exe',), 'winsta0\\private', None, None)
|
||||
|
||||
Reference in new issue
Block a user