Commits

Anonymous committed 992c3c0

Lenard's proc.kill() patch for async_sub.py

Comments (0)

Files changed (1)

     from win32pipe import PeekNamedPipe
     import win32api
     import msvcrt
-
 else:
     import select
     import fcntl
     if subprocess.mswindows:
         def kill(self):
             """kill function for Win32"""
-            handle = win32api.OpenProcess(1, 0, self.pid)
-            return (0 != win32api.TerminateProcess(handle, 0))
-        
+            try:
+                handle = win32api.OpenProcess(1, 0, self.pid)
+                try:
+                    win32api.TerminateProcess(handle, 0)
+                finally:
+                    win32api.CloseHandle(handle)
+            except win32api.error:
+                return False
+            return True
+
         def send(self, input):
             if not self.stdin:
                 return None