cobexit

Closes down the global COBOL run-time environment.
Restriction: This function is supported for native COBOL only.

Syntax:

#include "cobmain.h"

void cobexit (cobrtncode_t exitstatus);

Parameters:

exitstatus The exit status returned to the calling process.

Comments:

This function terminates a running application in the same way as if a COBOL STOP RUN statement had been executed, emptying buffers, closing files and freeing any data areas allocated by the COBOL system.

You must use the cobexit() function to exit from non-COBOL applications rather than just using the C library function exit().

This function will ultimately call exit() and so will not return.

The specified exit status is returned to the calling process. Standard operating system practice is to use an exit status of 0 on success.

The COBOL run-time system returns values of -1 (255) and -2 (254) if it exits due to an error or signal.

Equivalent COBOL Syntax:

stop run

Example:

To exit an application that has used COBOL, returning an error value of +123 to the parent process, use

cobexit(123);.