Tcl/Tk Extensions for Unix/Posix
Signal Extension (package Signal)
This extension adds dynamically loadable signal handling to Tcl/Tk scripts.
A configure script / autoconf is added, though only tested on a few kinds of
Unix so far.
Version 126.96.36.199 configuration was patched for Linux portability (and others)
by: Tilman Kranzemail@example.com
To ensure that signal handling does not happen at unsafe times (the X
library is still non-reentrant), and only occurs in the X loop,
the signal handler writes the signal number on a pipe,
which is handled through the Tcl file notification mechanism.
Just like you'd want in X.
If you can't wait that long, but want to wait until sometime -relatively- safe,
use the -async flag to create the handler (new in version 1.2).
Of course, the secretary will disavow all knowledge...
signal add signo proc [-async]
Adds a signal handler for signal signo through proc proc.
Signals can be provided by number, or the most common ones are provided by
name (e.g., SIGHUP).
The proc is any Tcl procedure, and it is evaluated when the signal comes in.
It will be provided no arguments.
Signal handlers have Posix semantics--they persist until reset.
If -async is used, the signal handler is created using Tcl_AsyncCreate().
Checks for the signal are very frequent (each evaluation) using this
technique, but one doesn't know quite where evaluation is or how to handle
errors in this situation. The code will evaluate the provided procedure in the
current interpreter if available, and in the interpreter which added the
signal handler otherwise. At least until a better scheme is suggested.
The -async is especially useful to interrupt "runaway" procs, or to cause a
quick exit; the default mechanism simply waits for another MainLoop cycle.
signal delete signo
Restores handling of signal signo to the default (SIG_DFL).
Prints the handling of all signals with handlers.
Formatted as signal name ----> procedure
or as signal name !---> procedure if the signal is handled
signal print signo
Compressed tar file for signal extension
version 1.4 (22199)
Prints the procedure for handling signal signo.
Prints the word UNHANDLED if no signal handler is active for that
Sample test code for catching interrupts and popping up
the window upon signal 21
Sample test code for catching interrupts
asynchronously, including breaking out of a calculation.