sending ctrl C to a program

Dale Strickland-Clark dale at riverhall.nospam.co.uk
Wed Mar 29 06:55:21 EST 2006


s99999999s2003 at yahoo.com wrote:

> hi
> i have a program that works very similar to tail -f in Unix
> It will need a Ctrl-C in order to break out of the program.
> I wish to run this program using python (either thru os.system() or
> some other subprocess modules) and how can i pass Ctrl-C to this
> program to terminate it in python?
> thanks

Isn't SIGINT the same as ctrl-c?

So something like 

import os
os.kill(1234, 2)

would send ctrl-c to process 1234.

If you just want the process to quit, you could probably just send it a
SIGTERM, which is signal 15.

-- 
Dale Strickland-Clark
Riverhall Systems - www.riverhall.co.uk
We're recruiting programmers. Please see the web site.




More information about the Python-list mailing list