durusmail: quixote-users: is_running on BSD systems
is_running on BSD systems
2005-03-04
2005-03-04
2005-03-04
2005-03-04
2005-03-04
2005-03-05
2005-03-05
2005-03-05
2005-03-05
2005-03-05
2005-03-05
2005-03-05
local.format_date_time
2005-03-11
Re: R: [Quixote-users] is_running on BSD systems
2005-03-07
2005-03-07
2005-03-07
Re: R: [Quixote-users] is_running on BSD systems
2005-03-07
is_running on BSD systems
Oleg Broytmann
2005-03-04
On Fri, Mar 04, 2005 at 04:46:34PM -0500, Michael Davidson wrote:
> def is_running(pid):
>     """Return true if program with 'pid' exists."""
>     # Currently Linux specific.
>     #return os.path.exists('/proc/%s' % pid)
>     from os import kill
>     try:
>         kill(int(pid),0)

   AFAIK this is the most correct and portable way.

>         return True
>     except OSError,e:
>         if e.errno == 1:  # exists, but no access
>             return True
>     return False

   Use symbolic name:

         if e.errno == errno.EPERM:  # exists, but no access

Oleg.
--
     Oleg Broytmann            http://phd.pp.ru/            phd@phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

reply