getpid Usage

david at tumbleweed.com david at tumbleweed.com
Thu Jul 13 13:02:20 EDT 2000


Is there some convenient way of getting os.getpid to return the PID of
a given executable? What I want to do is start a process and know it's
PID. When I do the following I get the PID of the python executable.

os.system("path")
os.getpid()

Alternatively, as a hack, I am doing:
os.system(self.m_server_start_exe)
for line in os.popen("ps -ef | grep -i IMEController | awk '{ if (NR >
1) { print $2 }}'").readlines():
            pid = line[:-1]

I would rather just path in an executable name/pathname and have it
return this process' pid. Is there an updated version of os.getpid I
could use to do this. If not, is there a better solution that is not
shell dependent?

Thanks,
David






More information about the Python-list mailing list