tcl.trap Verb: Access/TCL


Command tcl.trap Verb: Access/TCL
Applicable release versions: AP/Unix
Category TCL (746)
Description allows a TCL command (signal handler) to be executed upon receiving a specific signal.
The "trap" command traps a system-generated signal generated by the Pick monitor or by the Unix kernel and executes a TCL statement. Without any argument, lists the currently used signals.

"?" displays "help" and the list of user definable signals.

"*" specifies all user definable signals.

If the command is not specified, the signal handler is set to null, thus ignoring the signal. If a question mark (?) is used as a command, the signal handler, if any, of the specified signal is displayed.

If "command" is the keyword "default", the signal is reset to the default listed in the table in example 1. Otherwise, it may be any TCL command, including spaces and options.

Signal handlers are set for the whole virtual machine. When it is desirable to differentiate the signal handlers depending on the user or account, a Pick/BASIC program, a PROC or an environ script must be provided to execute commands selectively. The signal handler is executed by pushing a level. Therefore, the user might see some effect on the terminal (Update processor screen being re-displayed, for instance). If fifteen TCL levels are pushed when the signal occurs, it will not be processed. Signals are always pre-emptive, even upon their own signal handler. For a signal handler to be processed correctly, the process receiving the signal must be logged on.

signame is one of the valid user definable signal names:

"alrm" Stands for "alarm". When a Unix SIGALRM is generated, either by a Unix program called from the Pick process, or by the Pick/BASIC program calling the "%alarm()" C function, a signal is sent to the process. This signal can be used to log the process off, for instance, after a given time. The TCL "alarm" command generates this signal. The default action is to ignore the signal, therefore, an explicit "trap alrm" command must be used.

"dcd" Stands for Data Carrier Detect. If the DCD OFF protocol is active on one port, a HANGUP signal is generated by the terminal Unix driver when the DCD signal is dropped by the modem. The default handler logs the process off. On a network, a more complex program might be necessary to terminate the connection properly and must finish with a 'disc' command. See the section "hangup" for more details about the precautions to take when writing a signal handler for the loss of carrier.

"pwr" Stands for PoWeR off. When an imminent power failure is detected by Unix, the Kernel sends a SIGPWR signal to all active processes on the system. This signal is relayed to the Pick processes. Care must be taken to synchronize the default system handler (defined in the inittab) with the Pick handler. This signal might not be generated, depending on the hardware configuration.

"tdet" Stand for Tape DETach. When a "t-det (u)" command is issued, the process owner of the tape device receives this signal, so that the device can be closed properly. AP versions earlier than 6.1: Ignoring this signal will prevent the "t-det (u)" operation. The default signal handler just detaches the tape. AP versions 6.1 and later (multi-tape) : The handler for this signal is just a comment. It MUST NOT issue any tape command, including a "t-det".

"tdmof" Stands for TanDeM OFf. When the master process terminates, this displays "TANDEM TANDEM ON port.number". The slave terminal TERMINATED receives this signal.

"tdmon" Stands for TanDeM ON. When a process activates TANDEM, this displays "TANDEM STARTED ON port.number", both the master and slave terminals receive this signal.
Syntax trap { [*|signame] { [?|default|command] } }
Sig   Description      Handler
----- ---------------- --------------------------
tdmof Stop tandem      display TANDEM TERMINATED
tdmon Start tandem     display TANDEM STARTED
dcd   Modem hangup     off
mirof Stop mirror      display MIRROR TERMINATED
alrm  Alarm            run dm,bp, useralarm
tdet  t-det (U         display Tape detached with (U)
pwr   Power off        off

 List the current settings

trap * default
 Resets all signals to their default.

trap tdmon
Disables the signal associated with TANDEM.

trap tdmof display @(-13)TANDEM ENTERED@(-14)
Sets the TANDEM ON trap to display a message in reverse video.
Related tcl.dcd