Bind to Control-c without Tk bind?

Bind to Control-c without Tk bind?

Post by Syni » Thu, 17 Aug 2006 16:27:42


Hi guys.

I'm writing a Tcl app without Tk and would like to capture Control-c
gracefully. The bind command is unavailable.

invalid command name "bind" while executing
"bind . <Control-c> { set StopNow 1} "

What should I be using instead?

Cheers.
 
 
 

Bind to Control-c without Tk bind?

Post by suchenw » Thu, 17 Aug 2006 16:48:23


Synic schrieb:

In plain Tcl you can't. But with the Tclx extension, you can register a
signal handler:

proc mysig {} {
global cntrlc_flag
puts stdout "Aborting current routine"
set cntrlc_flag 0
}

signal trap SIGINT mysig

See http://www.yqcomputer.com/