Show More
@@ -10,6 +10,26 b' import time' | |||
|
10 | 10 | if os.name =='nt': |
|
11 | 11 | import ctypes |
|
12 | 12 | |
|
13 | _BOOL = ctypes.c_long | |
|
14 | _DWORD = ctypes.c_ulong | |
|
15 | _UINT = ctypes.c_uint | |
|
16 | _HANDLE = ctypes.c_void_p | |
|
17 | ||
|
18 | ctypes.windll.kernel32.CloseHandle.argtypes = [_HANDLE] | |
|
19 | ctypes.windll.kernel32.CloseHandle.restype = _BOOL | |
|
20 | ||
|
21 | ctypes.windll.kernel32.GetLastError.argtypes = [] | |
|
22 | ctypes.windll.kernel32.GetLastError.restype = _DWORD | |
|
23 | ||
|
24 | ctypes.windll.kernel32.OpenProcess.argtypes = [_DWORD, _BOOL, _DWORD] | |
|
25 | ctypes.windll.kernel32.OpenProcess.restype = _HANDLE | |
|
26 | ||
|
27 | ctypes.windll.kernel32.TerminateProcess.argtypes = [_HANDLE, _UINT] | |
|
28 | ctypes.windll.kernel32.TerminateProcess.restype = _BOOL | |
|
29 | ||
|
30 | ctypes.windll.kernel32.WaitForSingleObject.argtypes = [_HANDLE, _DWORD] | |
|
31 | ctypes.windll.kernel32.WaitForSingleObject.restype = _DWORD | |
|
32 | ||
|
13 | 33 | def _check(ret, expectederr=None): |
|
14 | 34 | if ret == 0: |
|
15 | 35 | winerrno = ctypes.GetLastError() |
@@ -27,7 +47,7 b" if os.name =='nt':" | |||
|
27 | 47 | handle = ctypes.windll.kernel32.OpenProcess( |
|
28 | 48 | PROCESS_TERMINATE|SYNCHRONIZE|PROCESS_QUERY_INFORMATION, |
|
29 | 49 | False, pid) |
|
30 |
if handle |
|
|
50 | if handle is None: | |
|
31 | 51 | _check(0, 87) # err 87 when process not found |
|
32 | 52 | return # process not found, already finished |
|
33 | 53 | try: |
General Comments 0
You need to be logged in to leave comments.
Login now