Previous: ExitCode variable To the Table of Content Next: FarPointer type

- 4.62.1.10 -
Standard Units
System Unit
System Unit Variables

ExitProc variable

Targets: MS-DOS, OS/2, Win32

System Unit

ExitProc, ExitCode, and ErrorAddr variables are used to implement exit procedures.

The ExitProc pointer variable allows one to install an exit procedure. The exit procedure always gets called as part of a program's termination.

An exit procedure takes no parameters and must be compiled with a far procedure directive to force it to use the far call model.

When implemented properly, an exit procedure actually becomes part of a chain of exit procedures. The procedures on the exit chain get executed in reverse order of installation.

To keep the exit chain intact, you must save the current contents of ExitProc before changing it to the address of your own exit procedure.

The first statement in your exit procedure must reinstall the saved value of ExitProc.

An exit procedure may learn the cause of termination by examining the ExitCode integer variable and the ErrorAddr pointer variable. The last exit procedure (the one installed by the run-time library) closes the Input and Output files. If ErrorAddr is not nil, it outputs a run-time error message.


Previous: ExitCode variable To the Table of Content Next: FarPointer type
ExitCode variable Table of Content FarPointer type

- 4.62.1.10 -