5.4.4 Program Termination and Return Values

When a child program uses End Program to terminate, MS-DOS closes files that the program opened, frees memory that the program allocated (including the memory occupied by the program code and data), and returns control to the parent program. The child program must restore any interrupt vectors it set before terminating.

A child program can specify a return value when it terminates, and its parent program can inspect the return value when it resumes running by using Get Child-Program Return Value. By convention, a return value of zero indicates success; increasingly large nonzero values indicate increasingly severe errors.

Get Child-Program Return Value places the child program's return value (if any) in the AL register and places one of the following termination-status values in the AH register:

Termination status Meaning

00h The child program terminated normally.
01h The child program terminated because the user pressed CTRL+C.
02h The child program was terminated by the critical-error handler.
03h The child program terminated normally and stayed resident.