$ZTIMeout

$ZTIMEOUT controls a single process wide timer. The format of the $ZTIMEOUT ISV is:

$ZTIMeout=([timeout][:labelref]) 

Note that GT.M only recognizes interrupts such as from $ZTIMEOUT at points where it can properly resume operation, such as the beginning of a line, when waiting on a command with a timeout, or when starting a FOR iteration. GT.M defers recognition of a $ZTIMEOUT arriving while executing a TP transaction until after a TROLLBACK or the "master" TCOMMIT. When a timeout occurs, if the last assignment specified no vector, GT.M uses the current $ETRAP or $ZTRAP. When a $ZTIMEOUT expires, it invokes one of three possible vectors:

In all cases the invoked code can alter the behavior using the tools at its disposal - for example, GOTO, ZGOTO, $ECODE, etc.

[Caution] Warning

When none of the vectors are specified, a $ZTIMEOUT expiration results in the termination of the process

Using a [Z}GOTO that stays within a $ZTIMEOUT labelref vector frame may cause undefined and undesirable behavior

GT.M rejects an attempted KILL of $ZTIMeout with the VAREXPECTED error and an attempted NEW of $ZTIMeout with the SVNONEW error.

Example:

GTM>zprint ^ztimeout
ztimeout
  ; Display $ztimeout
    write !,$ztimeout               ; display $ZTIMeout - in this case the initial value -1
                                    ; set with a vector (do ^TIMEOUT)
    set $ztimeout="60:do ^TIMEOUT"  ; timeout of 1 minute. After timeout expires, XECUTEs do ^TIMEOUT
    write !,$ztimeout               ; displays the remaining time:vector until timeout
  ; set without a vector
    set $ztimeout=120               ; set the timeout to 2 minutes without changing the vector
    set $ztimeout="1234do ^TIMEOUT" ; missing colon creates a timeout for 1234 seconds
    set $ztimeout="10:"             ; set the timeout to 10 seconds and vector to current etrap or ztrap
    set $ztimeout=-1                ; set cancels the timeout
  ; Note that set to 0 triggers an immediate timeout
    set $ztimeout=0                 ; triggers the current vector
    set $ztimeout="0:DO FOO"        ; this has the same effect as DO FOO
GTM>