Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get process status using pid?

Tags:

python

If I known a process's pid, how can I tell if the process is a zombie using Python ?

like image 825
Bdfy Avatar asked Jul 20 '11 19:07

Bdfy


People also ask

What command shows you the process used as PID 1?

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.

How do you find the PID of a process in python?

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.

How can I see what process a user is using?

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.


1 Answers

You could use a the status feature from psutil:

import psutil
p = psutil.Process(the_pid_you_want)
if p.status == psutil.STATUS_ZOMBIE:
    ....
like image 136
Mat Avatar answered Oct 01 '22 04:10

Mat