Normally you can't abort a REXX program in an external routine using the REXX statement exit. You have to use the OS/2 command exit to abort the main program. But this will also close the current OS/2 session ...
To avoid this misbehaviour, you either must call your REXX program with
cmd /c main
or you use the following code at the start of your main REXX program:
/* ------------------------------------------------------------------ */
/* main.cmd */
parse arg thisArgs 'FF'x pass
/* check the parameter to detect the current pass */
if pass <> '$$PASS2$$' then
do
/* cmd was called via "main" */
/* -> call it again using "cmd /c main" */
'@cmd /c %0 ' || thisArgs || 'FF'x || '$$PASS2$$'
exit
end /* if */
/* cmd was called via "cmd /c main" */
/* here goes the code of main .. */
say 'Now MAIN really starts ...'
say 'Arguments are "' || thisArgs || '"'
say 'Now calling TEST2.CMD ...'
call Test2.cmd
say 'MAIN is still running ...'
exit 0
/* ------------------------------------------------------------------ */
/* ------------------------------------------------------------------ */
/* test2.cmd - sample external REXX routine to show how it works */
say "TEST2.CMD starts .."
say "TEST2.CMD now aborts the MAIN program ..."
'@exit'
/* ------------------------------------------------------------------ */