[Tutor] os.system sending of break signals

R. Alan Monroe amonroe at columbus.rr.com
Fri Oct 28 00:24:15 CEST 2005

>> I send a command to os.system(cmd) and want to send a break signal in 
>> the same way. Is this possible? The break signal is ctrl c (^c).
>> I tried this, but it didn't work: os.system('\x03') I think Hex 03 is 
>> the signal for ctrl c.

> Its not possible with os.system because os.system runs the called 
> program to completion in a separate process. You would need to 
> mess about with threads and process ids to do it that way. However 
> if you use popen() (or maybe popen2()? )you should be able to send 
> a Ctrl-C character to the process. However whether that actually 
> terminates it will depend on the OS, the process and whether 
> Ctrl-C is being caught anywhere. But at least there's a chance 
> of it working!

Python has a "signal" module in the standard library. Will that work?


More information about the Tutor mailing list