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
Hi all -

I've been playing around a bit with Quixote, Durus, and Dulcinea. I'm
working on a variety of BSD-based machines (NetBSD, FreeBSD, OS X), and I
noticed that there are two Linux-specific hacks in Dulcinea. I don't know
the best way to submit a patch, but here's an alternate is_running (from
the 'site' script) that should work on BSD systems, assuming that 'ps' is
in your path. Should work in Linux too, but will obviously be slower than
the existing implementation.

In case anyone is interested, here it is:

def is_running(pid):
    """Return true if program with 'pid' exists."""
    from popen2 import popen2
    i,o = popen2("ps ax")
    ret = False
    for s in i.readlines():
        if pid == s.split()[0]:
            ret = True
            break
    i.close()
     o.close()
    return ret

Michael

reply