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
Michael Davidson
2005-03-04
On Sat, 05 Mar 2005, Oleg Broytmann (phd@mail2.phd.pp.ru) wrote:
>    That breaks on SysV.

I only claimed it worked on BSD and Linux, which (IMO) is better than just
Linux!

However, thanks for the tip. Try this:

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)
        return True
    except OSError,e:
        if e.errno == 1:  # exists, but no access
            return True
    return False

Michael

reply