JKEYAUTO WAIT

Man Page Index


Description

The WAIT statement can be used to wait until a program loaded with the PROGRAM statement has completed. It can also be used to see if it has already completed. Options exist for timing out the operation and checking the exit code of the child process.

Generally you should code this in all your scripts so that the jkeyauto program does not exit before the child processes created with the PROGRAM statement. Should this happen then jkeyauto will attempt to kill all remaining child processes when it exits.

 

Syntax

wait {PIPE expression_pipe} {FOR expression_for} {SETTING variable_setting}

expression_pipe shows what pipe number to wait for. The pipe number is obtained using the $PIPE variable following a PROGRAM statement execution. If this is omitted, then we wait for pipe number 0, which is the first pipe created with the first PROGRAM statement.

expression_for shows any timeout in seconds. A value of 0 shows to return straight away. If this option is omitted, then the WAIT statement will wait forever until the program completes. If the program specified has already completed, then this WAIT statement returns immediately regardless of this setting.

variable_setting allows you to find out the exit code of the program. It can be one of the following format

+ve number This is the exit code of the program.
Snnn. This shows the program terminated due to an un-caught signal, where nnn is the signal number that caused the programs death.
-1 This shows the WAIT statement returned because the timeout operation specified by exprssion_for was exceeded.
-2 This shows the value given in expression_pipe was invalid.

 

Example

time1 = $UBOOT
program "SLEEP 5"
pipeno = $PIPE
again:
wait PIPE pipeno FOR 2 SETTING s
IF s eq -2 then print "bad pipe number !" ; exit 2
IF s eq -1 then print "Still waiting to complete" ; goto again
time2 = $UBOOT
print "SLEEP exited with ":s:" and took ":time2-time1:" seconds"

In the above example we execute "SLEEP 5". We then go in a loop with a 2 second timeout displaying a "Still waiting to complete" every 2 seconds. When the program finally completes, we give the exit code from the program.


JKEYAUTO