This article explains the return code from the runtime system for abnormal terminations.
Problem:
A COBOL program can end "returning numeric-value" which will put a value in the return-code special register, but the COBOL runtime system can terminate abnormally before the program ends and this statement will never be executed. For example, a run time error 114 (memory bounds error) or 173 (called program not found) will cause abnormal termination of the runtime system. What return code one will one see via "echo $?" thereafter?
Resolution:
If the COBOL runtime system terminates due to an error, for example, program not found, RTS 114, etc., the return code is always 255.
If the runtime system terminates because the program terminates ("stop run" or top-level "goback"), the value of the return-code special register is returned.
The return code can be tested in a script or from the command line with the echo command. The variable is $? for all shells except the C shell, which uses $status.
Incident Number: 2359808