[Tutor] os.system sending of break signals

Johan Geldenhuys johan at accesstel.co.za
Fri Oct 28 11:57:02 CEST 2005

With what can I try and see what the PID is when using popen() or popen2() ?

One thing that I noticed now is that when using popen() and the 
sys.exit(). The command is completed before my Python shell is 
terminated and if I use popen2(), sys.exit() works immediately but the 
ping command runs still as a process untill completed.

Alan Gauld wrote:

>> >>> f = os.popen2('ping -c 100 > cap1.txt')
>> >>> f[0].write('\x03')
>> Thank command works, but 'f[1]' is in read-only mode and I can't 
>> write to it.
>> My command in the background is still not terminated.
> Thats almost certainly because ping never reads its input.
> In that case you'll need to send a kill signal to the process and
> to do that you need to find the process ID. I'm not sure if popen() 
> provides access to the PID but if not you could either search for it 
> (this might be too slow) or just drop down to use fork rather than 
> popen, as fork will return the PID.
> Alan G.

More information about the Tutor mailing list