On 04/26/2012 02:24 PM, Sean Carolan wrote:
> In bash you can do this to see if a process is running:
>
> [scarolan@kurobox:~/bin]$ kill -0 24275
> [scarolan@kurobox:~/bin]$ echo $?
> 0
>
> Is there a python equivalent? I tried using os.kill() but did not see
> any way to capture the output.
You might start with something like this ...
# python2.x
try:
os.kill(24275, 0)
except OSError, e:
if e.errno != 3: # 3 = No such process
raise
# process is not running, do something
else:
# process is running, do something
It would seem os.kill returns nothing if the signal is sent
successfully, and will raise an exception if not.
HTH!
Marty
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor