Using os.getpid

david at tumbleweed.com david at tumbleweed.com
Thu Jul 13 13:29:39 EDT 2000


When I do the following I get the PID of my python program:

os.system(self.m_server_start_exe)
os.getpid()

I have hacked up the following workaround:
os.system(self.m_server_start_exe)
for line in os.popen("ps -ef | grep -i
/opt/tumbleweed/server/bin/IMEController | awk '{ if (NR > 1) { print
$0 }}'").readlines():
    pid = line[:-1]

Is there a version of os.getpid() that takes as an argument an
executable name/pathname and returns its PID? Or, is there a better
way to do this using existing modules and tools that isn't shell
and/or platform dependent?






More information about the Python-list mailing list