PS. At the end, I used
WaitForPort because it straightforward and it either returns 0 immediately (if the port is available) or timeouts after 10 sec. and returns 5 (if the port is unavailable).
Code:
IF ~SHOW('P', programPort) THEN DO
ADDRESS Command 'Run >' || tempFile || ' ' || programName
ADDRESS Command 'WaitForPort ' || programPort
IF RC ~= 0 THEN DO
SAY 'Could not start ' || programName || ', is it in the path?'
EXIT
END
SAY programName || ' has started.'
END
ELSE DO
SAY programName || ' was already started.'
END