signal action siglist ?command?
Warning: The behavior of signals under Unix
doesn't make signals a general event mechanism.
Interrupted system calls, caused by signals, can
cause errors in code where they are not expected.
This can cause a program to behave in unexpected
ways. In general, the only safe usage for signals
is to generate errors to terminate a blocked opera-
tion.
Specify the action to take when a Unix signal is
received by Extended Tcl, or a program that embeds
it. Siglist is a list of either the symbolic or
numeric Unix signal (the SIG prefix is optional).
Action is one of the following actions to be per-
formed on receipt of the signal. To specify all
modifiable signals, use `*' (this will not include
SIGKILL and SIGSTOP, as they can not be modified).
default - Perform system default action when signal
is received (see signal system call documentation).
ignore - Ignore the signal.
error - Generate a catchable Tcl error. It will be
as if the command that was running returned an
error. The error code will be in the form:
POSIX SIG signame
For the death of child signal, signame will always
be SIGCHLD, rather than SIGCLD, to allow writing
portable code.
trap - When the signal occurs, execute command and
continue execution if an error is not returned by
command. The command will be executed in the
global context. The command will be edited before
execution, replacing occurrences of "%S" with the
signal name. Occurrences of "%%" result in a sin-
gle "%". This editing occurs just before the trap
command is evaluated. If an error is returned,
then follow the standard Tcl error mechanism.
Often command will just do an exit.
get - Retrieve the current settings of the speci-
fied signals. A keyed list will be returned were
the keys are one of the specified signals and the
values are a list consisting of the action associ-
ated with the signal, a 0 if the signal may be
delivered (not block) and a 1 if it is blocked. The
actions maybe one of `default',`ignore', `error' or
`trap. If the action is trap, the third element is
the command associated with the action. The action
`unknown' is returned if a non-Tcl signal handler
has been associated with the signal.
set - Set signals from a keyed list in the format
returned by the get. For this action, siglist is
the keyed list of signal state. Signals with an
action of `unknown' are not modified.
block - Block the specified signals from being
received. (Posix systems only).
unblock - Allow the specified signal to be
received. Pending signals will not occur. (Posix
systems only).
The signal action will remain enabled after the
specified signal has occurred. The exception to
this is SIGCHLD on systems without Posix signals.
For these systems, SIGCHLD is not be automatically
reenabled. After a SIGCHLD signal is received, a
call to wait must be performed to retrieve the exit
status of the child process before issuing another
signal SIGCHLD ... command. For code that is to be
portable between both types of systems, use this
approach.
Signals are not processed until after the comple-
tion of the Tcl command that is executing when the
signal is received. If an interactive Tcl shell is
running, then the SIGINT will be set to error, non-
interactive Tcl sessions leave SIGINT unchanged
from when the process started (normally default for
foreground processes and ignore for processes in
the background).
This command is provided by Extended Tcl.