From 5bf87bc64dd39a400701175d448b2e15e12afa8e Mon Sep 17 00:00:00 2001 From: j Date: Tue, 29 Jan 2019 19:09:25 +0530 Subject: [PATCH] windows check_pid --- oml/utils.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/oml/utils.py b/oml/utils.py index 5130156..6e6d924 100644 --- a/oml/utils.py +++ b/oml/utils.py @@ -369,12 +369,23 @@ def update_static(): ) def check_pid(pid): - try: - os.kill(pid, 0) - except: - return False + if sys.platform == 'win32': + import ctypes + kernel32 = ctypes.windll.kernel32 + SYNCHRONIZE = 0x100000 + process = kernel32.OpenProcess(SYNCHRONIZE, 0, pid) + if process != 0: + kernel32.CloseHandle(process) + return True + else: + return False else: - return True + try: + os.kill(pid, 0) + except: + return False + else: + return True def check_pidfile(pid): try: