The HANG command suspends GT.M program execution for a period of time specified by the command argument.
The format of the HANG command is:
The optional truth-valued expression immediately following the command is a command postconditional that controls whether or not GT.M executes the command.
The numeric expression specifies the time in seconds to elapse before resuming execution; actual elapsed time may vary slightly from the specified time. If the numeric expression is negative, HANG has no effect. Portability requirements for GT.M only guarantee accuracy to the nearest second. However, more accuracy can be found on different UNIX systems.
An indirection operator and an expression atom evaluating to a list of one or more HANG arguments form a legal argument to a HANG.
A process that repeatedly tests for some event, such as a device becoming available or another process modifying a global variable, may use a HANG to limit its consumption of computing resources.
Because HALT and HANG share the same abbreviation (H), GT.M differentiates them based on whether an argument follows the command.
For Quit:$Data(^CTRL(1)) Hang 30
This FOR loop repeatedly tests for the existence of ^CTRL(1), and terminates when that global variable exists. Otherwise the routine HANGs for 30 seconds and tests again.
SET t=1 For Quit:$Data(^CTRL(1)) Hang t If t<30 Set t=t+1
This is similar to the previous example, except that it uses an adaptive time that lengthens from 1 second to a limit of 30 seconds if the routine stays in the loop.