On May 21, 12:13 pm, Roy Smith <[EMAIL PROTECTED]> wrote:
> In article
> <[EMAIL PROTECTED]>,
>
>  bukzor <[EMAIL PROTECTED]> wrote:
> > Does anyone have a pythonic way to check if a process is dead, given
> > the pid?
>
> > This is the function I'm using is quite OS dependent. A good candidate
> > might be "try: kill(pid)", since it throws an exception if the pid is
> > dead, but that sends a signal which might interfere with the process.
>
> > Thanks.
> > --Buck
>
> The canonical way is to do kill(pid, 0).  If it doesn't throw, the process
> exists.  No actual signal is sent to the process either way.
>
> Of course, the process could exit immediately after the kill() call, so by
> the time you find out it's alive, it's dead.  Such is life.

Thanks! That's exactly what I was looking for. A little more
background:

"If sig is 0 (the null signal), error checking is performed but no
signal is actually sent. The null signal can be used to check the
validity of pid."

Taken from : http://www.opengroup.org/onlinepubs/009695399/functions/kill.html
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to