How to get os.popen subprocess PID?

Ricardo nospam at here
Thu Sep 5 13:59:48 EDT 2002


> I have a subprocess opened with os.popen, producing undefined length of
> data.  I want to read maybe some of this data and then get rid of the
> subprocess, not waiting until the end of data.  I have thought of
> os.kill-ing the process.  So far I haven't been able to determine how to
> get the pid of the subprocess, required by os.kill .. Any pointers?
>

Instead of using os.popen() you could import the popen2 module and use the
Popen3 or Popen4 classes.

Objects of these classes contain a 'pid' attribute.








More information about the Python-list mailing list