def process__get_exit_code(thread_pid):
"""
:param thread_pid:
:return: None if the process hasn't exited, or the int exit code.
"""
hproc = windll.kernel32.OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, False, thread_pid)
try:
exit_code = wintypes.DWORD()
if GetExitCodeProcess(hproc, byref(exit_code)) != 0:
if exit_code == STILL_ACTIVE:
return None
return int(exit_code)
raise WinError()
finally:
windll.kernel32.CloseHandle(hproc)
评论列表
文章目录