CRE Programmer's Guide
CRE Services
Common Run-Time Environment (CRE) Programmer’s Guide—528146-004
2-16
CRE_Terminator_ Procedure
the C exit() function, the compiler generates a call to a language-specific run-time 
library function for program termination. For programs that run in the TNS CRE, the 
language-specific run-time library function calls the CRE_Terminator_ procedure.
CRE_Terminator_ Procedure
The syntax used to call the CRE_Terminator_ procedure is described in Section 6, 
CRE Service Functions. CRE_Terminator_ performs the following tasks:
•
In the TNS environment, it invokes a language-specific termination function for 
each language, except TAL, represented in your program. In the native 
environment, it invokes a NonStop operating system routine that calls all shared 
run-time library termination routines. 
•
If your program terminates normally or because of a logic problem:
°
Closes standard input if it is open.
°
Ensures that all records in CRE buffers for standard output and standard log 
are written, and closes standard output and standard log.
The CRE closes only the three standard files. All other files are closed from the 
run-time library function or user routine that opened them. Otherwise, they are 
closed implicitly when the CRE calls the PROCESS_STOP_ system procedure.
•
Invokes PROCESS_STOP_, passing it CRE_Terminator_ parameters that 
correspond to PROCESS_STOP_ parameters.
Handling Error Conditions in CRE_Terminator_
If an error occurs while CRE_Terminator_ is executing, CRE_Terminator_ terminates 
your program as smoothly as possible by taking the following actions:
•
If CRE_Terminator_ detects that its data has been corrupted, it repairs the 
corrupted data if possible. If it cannot repair the corrupted data, CRE_Terminator_ 
invokes PROCESS_STOP_, specifying ABEND and the text “Corrupted 
environment.”
•
If a trap occurs in the TNS environment while CRE_Terminator_ is terminating your 
program, CRE_Terminator_ invokes PROCESS_STOP_, specifying ABEND and 
the text “Trap during termination.”
•
If a signal occurs in the native environment while CRE_Terminator_ is terminating 
your program, CRE_Terminator_ invokes PROCESS_STOP_, specifying ABEND 
and the text “Signal during termination.”
•
If your program does not pass the Completion_Status parameter to 
CRE_Terminator_, CRE_Terminator_ attempts to write the message “Missing or 
invalid parameter” to standard log. If for any reason CRE_Terminator_ cannot write 
the message, it uses a generic CRE completion error value for the status code and 
reports the text “Missing or invalid parameter.”










