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.