[Tutor] os.system sending of break signals

Alan Gauld alan.gauld at freenet.co.uk
Fri Oct 28 00:15:51 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!

HTH,

Alan G
Author of the learn to program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld




More information about the Tutor mailing list