Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

exit, _exit, _Exit - Program termination

&pagelevel(4)&pagelevel

Definition

#include <stdlib.h>

void exit(int status); (nicht C11)

_Noreturn void exit(int status); (C11)
_Noreturn void _Exit(int status); (C11)

void _exit(int status);


exit

terminates the program.

First, the termination routines registered with the atexit function are called in the
reverse order of their registration. If a routine has been registered more than once
it is also called more than once.
All files opened by the program are then closed and the following messages are
output to stderr:

  • “CCM0998 used CPU-time t seconds”, if CPU-TIME=YES is set in the
    RUNTIME option

  • “CCM0999 exit status”, if status != EXIT_SUCCESS (value 0)

  • "CCM0999 exit FAILURE", if status = EXIT_FAILURE (value 9990888).


_exit,
_Exit


also terminate the program.
_Exit is the C11-conform synonym for _exit.

In contrast to exit, the termination routines registered with atexit are not called and open files are not closed. Only the message "CCM0999 exit status" is output (if status != EXIT_SUCCESS).

Depending on the value of the status parameter, the status indicator of the monitoring job variable (1st to 3rd byte) is set to the value "$T " or "$A ".

Parameters

int status

This parameter may contain the following values:

      • the symbolic constants EXIT_SUCCESS and EXIT_FAILURE defined in the include file <stdlib.h>,
      • or any integer value.

EXIT_SUCCESS (value 0)

causes normal program termination.

The status indicator of the MONJV is assigned the value "$T ". In addition, the following settings are made: SUBCODE1=0, MAINCODE =CCM0998 and  SUBCODE2=status modulo 256

EXIT_FAILURE (value 9990888)

causes a so-called job-step termination:

            • The program is terminated abnormally.

            • In a DO or CALL procedure, the system branches to the next ABEND, END-PROCEDURE, SET-JOB-STEP or LOGOFF command.

            • The system message "ABNORMAL PROGRAM TERMINATION" is issued.

The status indicator of the MONJV is assigned the value "$A ", and SUBCODE1=64, MAINCODE=CCM0999 and SUBCODE2=status modulo 256 are set.

integer value

If this value is not equal to the predefined values EXIT_SUCCESS and EXIT_FAILURE (!= 0 or !=9990888), a job-step termination is performed, and the status indicator of the MONJV is assigned the value "$T". Furthermore, SUBCODE1=64, MAINCODE=CCM0999, and SUBCODE2=status modulo 256 are set.

If this value corresponds to the predefined values EXIT_SUCCESS or  EXIT_FAILURE, the actions indicated above are performed.

Notes

Functions registered by at_quick_exit are not called.

In order to be able to set and query monitoring job variables, you must start the C program with the following command:

/START-PROG program,MONJV=monjvname

The content of the job variable can then be queried, e.g. with the following command:

/SHOW-JV JV-NAME(monjvname)

Further information on job monitoring using monitoring job variables can be found in the "Job Variables" manual.

See also

abort, atexit, at_quick_exit, bs2exit, quick_exit, signal