Blocking ctrl-c to os.popen() or os.system()
Jarkko Torppa
torppa at staff.megabaud.fi
Sat Jan 4 23:54:10 EST 2003
In article <qwOR9.108503$6H6.3599736 at twister.austin.rr.com>, Sandeep Gupta wrote:
> I am running on Linux, but the script I'm writing will also be using on
> Win2k.
>
> What I meant was I start the command and programatically wait for it to
> finish. I wait for the command to finish by doing an f.read() on the stdout
> returned from popen*(). While I am waiting for it to finish, if the user
> types ctrl-c, the command receives the interrupt.
>
> But if my command is "cvs diff", cvs receives the ctrl-c.
>
> Any other suggestions?
If your cvs is doing remote stuff it's most propably ssh/rsh that is
trying to grab terminal directly, ssh has some flags that
might help.
This might also help, unless it also enables tty signal processing
import termios,TERMIOS,copy,sys
oat=termios.tcgetattr(sys.stdin.fileno())
at=termios.tcgetattr(sys.stdin.fileno())
at[3]=at[3] & ~TERMIOS.ISIG
termios.tcsetattr(sys.stdin.fileno(),TERMIOS.TCSANOW,at)
(popen here)
termios.tcsetattr(sys.stdin.fileno(),TERMIOS.TCSANOW,oat)
This most propably does not work on windows
--
Jarkko Torppa
More information about the Python-list
mailing list