How to get process status using pid?
here's a quick hack using procfs
(assuming you're using Linux):
def procStatus(pid):
for line in open("/proc/%d/status" % pid).readlines():
if line.startswith("State:"):
return line.split(":",1)[1].strip().split(' ')[0]
return None
this function should return 'Z'
for zombies.
You could use a the status
feature from psutil:
import psutil
p = psutil.Process(the_pid_you_want)
if p.status == psutil.STATUS_ZOMBIE:
....