Hello there,
Is there a simple way to find if process is running or not running using pid alone.
There is psutil.pid_exits() functions which does work indeed. However just for a sake of one feature installing psutil seems to be meaningless.
Is there a way to find out if process exist using pid without psutil.
I have tried using ctypes below code, from stackoverflow,
the code:
import ctypes
PROCESS_QUERY_INFROMATION = 0x1000
def checkPid(pid):
processHandle = ctypes.windll.kernel32.OpenProcess(PROCESS_QUERY_INFROMATION, 0,pid)
if processHandle == 0:
return False
else:
ctypes.windll.kernel32.CloseHandle(processHandle)
return True
But it sometimes return True even if process does not exists. Ps util correctly returns False.
I have tried using win32process and querying via wmi win32process but that is too much cpu utilization