popen3 and PID - how?
Donn Cave
donn at u.washington.edu
Thu May 27 12:03:50 EDT 1999
Simon Budig <simon at unix-ag.uni-siegen.de> writes:
| I tried to write a small program in python, which parses the output of
| another command. So I did
|
| (foo, bar, baz) = popen3 ("/bin/foobar")
|
| line = foo.readline()
| while line != ´´:
| do something...
|
| The problem is: Sometimes I have to send the "foobar"-Program a signal.
| How can I get the PID of this process?
The source for popen3() is in /usr/local/lib/python1.5/popen2.py (or
somewhere like that, depending on your site.) You'll find that popen3()
is merely a couple of lines that create a Popen3 class instance and
return references to its pipe files. If you use the class directly,
instead of the function, its PID is an attribute of the instance.
Donn Cave, University Computing Services, University of Washington
donn at u.washington.edu
More information about the Python-list
mailing list