I am running on a Linux x86-64 system. From a Python (2.6) script, I wish to periodically check whether a given process (identified by pid) has become "defunct"/zombie (this means that entry in the process table exists but the process is doing nothing). It would be also good to know how much CPU the process is consuming (similar to what 'top' command shows).
Can somebody give me some pointers on how I can get these in Python?
pscommand via subprocess.Popen(). Each line is a process and a Z in the STAT column means you've got a zombie. ps has a ton of parameters (man ps) and can give you a lot of information.