var output,input,stderr : text; exitproc : pointer; exitcode : word; stackbottom : Cardinal; |
When a program halts (be it through the call of the Halt function or Exit or through a run-time error), the exit mechanism checks the value of ExitProc. If this one is non-Nil, it is set to Nil, and the procedure is called. If the exit procedure exits, the value of ExitProc is checked again. If it is non-Nil then the above steps are repeated. So when an exit procedure must be installed, the old value of ExitProc should be saved (it may be non-Nil, since other units could have set it). In the exit procedure the value of ExitProc should be restored to the previous value, such that if it was non-Nil the exit-procedure can be called.
Listing: refex/ex98.pp
The ErrorAddr and ExitCode can be used to check for error-conditions. If ErrorAddr is non-Nil, a run-time error has occurred. If so, ExitCode contains the error code. If ErrorAddr is Nil, then ExitCode contains the argument to Halt or 0 if the program terminated normally.
ExitCode is always passed to the operating system as the exit-code of the current process.
Remark: The maximum error code under LINUX and UNIX like operating systems is 127. Under GO32, the following constants are also defined :
const seg0040 = $0040; segA000 = $A000; segB000 = $B000; segB800 = $B800; |
The randomize function uses a seed stored in the RandSeed variable:
RandSeed : Cardinal; |
Other variables indicate the state of the application.
IsLibrary : boolean; IsMultiThread : boolean; |