471,350 Members | 1,650 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

Get the status of a process

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.

--
Gilles

Jul 18 '05 #1
2 2457
Gilles Lenfant <no*************@bigfoot.com> writes:
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

--
Gullible editorial staff continues to post links to any and all
articles that vaguely criticize Linux in any way.
-- Reason #4 for quitting slashdot today, from
http://www.cs.washington.edu/homes/k.../slashdot.html
Jul 18 '05 #2
Michael Hudson wrote:

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)

--
Gilles

Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Ishwar Rattan | last post: by
8 posts views Thread by mark4asp | last post: by
3 posts views Thread by bygandhi | last post: by
1 post views Thread by Francis | last post: by
18 posts views Thread by mistral | last post: by
reply views Thread by Edwin.Madari | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.