If I known a process's pid, how can I tell if the process is a zombie using Python ?
1) Finding a process ID (PID) with pidof command The pidof command is used to find the process ID of the running program. It prints those IDs into the standard output.
We can get the pid for the current process via the os. getpid() function. We may also get the pid for the parent process via the os. getppid() function.
Open the terminal window or app. To see only the processes owned by a specific user on Linux run: ps -u {USERNAME} Search for a Linux process by name run: pgrep -u {USERNAME} {processName} Another option to list processes by name is to run either top -U {userName} or htop -u {userName} commands.
You could use a the status
feature from psutil:
import psutil
p = psutil.Process(the_pid_you_want)
if p.status == psutil.STATUS_ZOMBIE:
....
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With