David Gravereaux wrote:
> I was thinking about this some more and I don't think this signal
> stuff should be in tclsh at all.
>
> It should be in an extension or something.
>
> Here's why I think this.. To properly "trap" a signal I need to
> assume the event loop is running. I think that's a bad asumption to
> make for everyone by placing this code in the shell itself.
Why are you thinking in terms of something so elaborate? The async stuff
(Tcl_AsyncCreate/Tcl_AsyncMark) is designed specifically for handling
interrupts, and the interpreter always services the async stuff (using
Tcl_AsyncReady) when it is in a reentrant state. Fiddling around with
lots of thread stuff is just a way to get confused. (The async API is
how the TclX and Expect extensions handle signals on UNIX.)
Of course, the async handler you set up with Tcl_AsyncCreate could just
post an event to the event queue. That'd work just fine. But that's a
higher-level operation, and could be written in Tcl because you've got a
reentrant interpreter by the time it runs...
Donal.
Received on Tue Jan 3 03:09:53 2006