##// END OF EJS Templates
killdaemons: fix WaitForSingleObject() error handling logic on Windows...
Matt Harbison -
r32858:ed1f3760 default
parent child Browse files
Show More
@@ -44,6 +44,7 b" if os.name =='nt':"
44 SYNCHRONIZE = 0x00100000
44 SYNCHRONIZE = 0x00100000
45 WAIT_OBJECT_0 = 0
45 WAIT_OBJECT_0 = 0
46 WAIT_TIMEOUT = 258
46 WAIT_TIMEOUT = 258
47 WAIT_FAILED = _DWORD(0xFFFFFFFF).value
47 handle = ctypes.windll.kernel32.OpenProcess(
48 handle = ctypes.windll.kernel32.OpenProcess(
48 PROCESS_TERMINATE|SYNCHRONIZE|PROCESS_QUERY_INFORMATION,
49 PROCESS_TERMINATE|SYNCHRONIZE|PROCESS_QUERY_INFORMATION,
49 False, pid)
50 False, pid)
@@ -56,8 +57,8 b" if os.name =='nt':"
56 pass # terminated, but process handle still available
57 pass # terminated, but process handle still available
57 elif r == WAIT_TIMEOUT:
58 elif r == WAIT_TIMEOUT:
58 _check(ctypes.windll.kernel32.TerminateProcess(handle, -1))
59 _check(ctypes.windll.kernel32.TerminateProcess(handle, -1))
59 else:
60 elif r == WAIT_FAILED:
60 _check(r)
61 _check(0) # err stored in GetLastError()
61
62
62 # TODO?: forcefully kill when timeout
63 # TODO?: forcefully kill when timeout
63 # and ?shorter waiting time? when tryhard==True
64 # and ?shorter waiting time? when tryhard==True
@@ -67,8 +68,8 b" if os.name =='nt':"
67 pass # process is terminated
68 pass # process is terminated
68 elif r == WAIT_TIMEOUT:
69 elif r == WAIT_TIMEOUT:
69 logfn('# Daemon process %d is stuck')
70 logfn('# Daemon process %d is stuck')
70 else:
71 elif r == WAIT_FAILED:
71 _check(r) # any error
72 _check(0) # err stored in GetLastError()
72 except: #re-raises
73 except: #re-raises
73 ctypes.windll.kernel32.CloseHandle(handle) # no _check, keep error
74 ctypes.windll.kernel32.CloseHandle(handle) # no _check, keep error
74 raise
75 raise
General Comments 0
You need to be logged in to leave comments. Login now