Get the status of a process

G

Gilles Lenfant

Hi,

I'm pretty brain dead reading the python docs about the processes.

I'm looking for some pythonig way to do a...

$ ps x | grep <some_pid>

.... in order to know if <some_pid> is running or not.

Thanks in advance for any hint.
 
M

Michael Hudson

Gilles Lenfant said:
Hi,

I'm pretty brain dead reading the python docs about the processes.

I'm looking for some pythonig way to do a...

$ ps x | grep <some_pid>

... in order to know if <some_pid> is running or not.

Thanks in advance for any hint.

os.kill(some_pid, 0)?

You might get EPERM if the process is running, but as a different
user.

Cheers,
mwh
 
G

Gilles Lenfant

Michael said:
os.kill(some_pid, 0)?

You might get EPERM if the process is running, but as a different
user.

Cheers,
mwh

Many thanks. This does the job (raises an OSError when process is dead)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top