How do I check if a pid is running?
moray.grieve
moray.grieve at ntlworld.com
Fri May 10 09:08:42 EDT 2002
You could do a system call on unix to get a list of all pids belonging to
yourself i.e.
lines = os.popen( "ps -u %s -o pid,comm"%(getpass.getuser()) ).readlines()
pids = []
for line in lines:
pids.append(string.atoi(string.split(line)[0]))
You could then search through the list to see if the pid you are interested
is in there. I use this approach on both Solaris and Red Hat.
Cheers,
Moray Grieve
More information about the Python-list
mailing list