On Mar 13, 2025, at 8:04 AM, Simon Sobisch <simonsobi...@gnu.org> wrote:
> 
> exit() allows us to "pass to the operating system" directly; but it doesn't 
> directly say "success" or "fail".
> 
> 
> Obviously the statements
>   STOP RUN WITH NORMAL STATUS 41
> and
>   STOP RUN ERROR 41
> 
> Should have a different result for the operating system.

Or, obviously not.  

For OSes I'm familiar with, there is no *definition* of success/failure.  
There's just convention: 0 is success and nonzero failure.  Even that is 
honored in the breach, see diff(1).  

IMO unless the OS defines success/failure outside the value of the exit status 
value (above, 41), the COBOL compiler cannot supply meaning to STOP RUN NORMAL 
or ERROR.  It has no meaning in COBOL because it has no meaning outside COBOL.  

By that reasoning, the two statements above both return 41 because there is no 
way to say more.  It is for the caller to decide what to do.  

I do not think -41 is an option; the compiler should not make arbitrary changes 
to the user's data.  

It is temping to raise(SIG_TERM) for error, but again the 41 is lost.  

> STOP RUN WITH ERROR "Don't do that, Jon!"

When no numeric value is supplied, IMO: 

    • STOP RUN WITH NORMAL STATUS becomes exit(EXIT_SUCCESS)
    • STOP RUN WITH ERROR becomes exit(EXIT_FAILURE)

That satisfies the Principle of Least Astonishment.  BTW those values are 
defined by C, not POSIX.  

--jkl



Reply via email to