$ZTE[XIT] contains a string value that controls the GT.M interrupt facility at the transaction commit or rollback. At each outermost TCOMMIT or TROLLBACK, If +$ZTEXIT evaluates to non-zero (TRUE), then $ZINTERRUPT is XECUTEd after completing the commit or rollback.
$ZTEXIT is a read-write ISV, that is, it can appear on the left side of the equal sign (=) in the argument to the SET command. M routines cannot NEW $ZTEXIT. GT.M initializes $ZTEXIT to null at the process startup. Note that the changes to the value of $ZTEXIT during a GT.M invocation last for the entire duration of the process, so it is the application’s responsibility to reset $ZTEXIT after $ZINTERRUPT is delivered in order to turn off redelivering the interrupt each every subsequent transaction commit or rollback.
Example:
ztran.m foo; set $zte=1 set $zint="d ^throwint" tstart () for i=1:1:10 do . set ^ACN(i,"bal")=i*100 tstart () do ^throwint do ^proc tcommit:$tlevel=2 for i=1:1:10 do . set ^ACN(i,"int")=i*0.05 do ^srv if $tlevel trollback do ^exc set $zte="",$zint="" quit bar; write "Begin Transaction",! set $zte=1 tstart () i '$zsigproc($j,$ztrnlnm("sigusrval")) w "interrupt sent...",!! for i=1:1:4 set ^B(i)=i*i tcommit write "End Transaction",! do ^srv quit throwint.m thrint set $zint="write !,""interrupt occurred at : "",$stack($stack-1,""PLACE""),! set $zte=1" if '$zsigproc($j,$ztrnlnm("sigusrval")) write "interrupt sent to process" write "***************************************",!! quit
Example:
GTM>d foo^ztran interrupt sent to process interrupt occurred at : thrint+3^throwint *************************************** interrupt occurred at : foo+13^ztran GTM>
In the above call to foo^ztran, the interrupt handler is a user-defined routine, throwint. The process is sent a signal (SIGUSR1), and $ZINTERRUPT is executed. At the outermost trollback, the interrupt is rethrown, causing $ZINTERRUPT to be executed again.
Example:
GTM>w $zint IF $ZJOBEXAM() GTM>f s x=$zsearch("GTM_JOBEXAM.*") q:x="" w !,x GTM>d bar^ztran Begin Transaction interrupt sent... End Transaction GTM>f s x=$zsearch("GTM_JOBEXAM.*") q:x="" w !,x DISK$TESTAREA3:[V967.ZTE]GTM_JOBEXAM.ZSHOW_DMP_541068433_1;1 DISK$TESTAREA3:[V967.ZTE]GTM_JOBEXAM.ZSHOW_DMP_541068433_2;1 GTM>
This uses the default value of $ZINTERRUPT to service interrupts issued to the process. The $ZJOBEXAM function executes a ZSHOW "*", and stores the output in each GTM_ZJOBEXAM_ZSHOW_DMP for the initial interrupt, and at tcommit when the interrupt is rethrown.