home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pmos2002.zip / DEF / FINALEXI.DEF < prev    next >
Text File  |  1996-10-23  |  3KB  |  55 lines

  1. DEFINITION MODULE FinalExit;
  2.  
  3.         (****************************************************************)
  4.         (*                                                              *)
  5.         (*           Support for program termination procedures         *)
  6.         (*                                                              *)
  7.         (*  The facility provided is that the caller can specify any    *)
  8.         (*  number of parameterless procedures to be called when the    *)
  9.         (*  program terminates.  This allows each module which needs it *)
  10.         (*  to have a final cleanup procedure to do things like         *)
  11.         (*  releasing allocated memory, closing open files, etc.  The   *)
  12.         (*  termination procedures are called in a last-in first-out    *)
  13.         (*  order, which generally means that the higher-level modules  *)
  14.         (*  are dealt with before lower-level modules (which is usually *)
  15.         (*  what we want).                                              *)
  16.         (*                                                              *)
  17.         (*  Multipass termination processing is supported by allowing   *)
  18.         (*  any termination handler to itself install another handler.  *)
  19.         (*  In such a case the new handler is not executing until the   *)
  20.         (*  current list of waiting handlers is exhausted.  Multipass   *)
  21.         (*  processing is needed when, for example, part of a module    *)
  22.         (*  shutdown cannot be completed until it is guaranteed that    *)
  23.         (*  all multitasking has ceased.                                *)
  24.         (*                                                              *)
  25.         (*      Programmer:     P. Moylan                               *)
  26.         (*      Last edited:    23 October 1996                         *)
  27.         (*      Status:         OK                                      *)
  28.         (*                                                              *)
  29.         (****************************************************************)
  30.  
  31. PROCEDURE SetTerminationProcedure (TP: PROC);
  32.  
  33.     (* Adds TP to the list of procedures which will be called just      *)
  34.     (* before program termination.  The list is ordered such that the   *)
  35.     (* last procedure added will be the first one called.  Exception:   *)
  36.     (* if termination is already in progress when this procedure is     *)
  37.     (* called, then TP will not be called until all of the existing     *)
  38.     (* termination procedures have been called.  This rule permits      *)
  39.     (* multi-pass termination processing, where necessary, by letting   *)
  40.     (* termination procedures themselves install more termination       *)
  41.     (* procedures.                                                      *)
  42.  
  43. PROCEDURE Crash (message: ARRAY OF CHAR);
  44.  
  45.     (* Terminates the program with an error report.     *)
  46.  
  47. PROCEDURE TerminationMessage (VAR (*OUT*) message: ARRAY OF CHAR): BOOLEAN;
  48.  
  49.     (* Returns the message supplied by the caller of the Crash          *)
  50.     (* procedure.  The function result is TRUE if such a message        *)
  51.     (* exists, and FALSE if Crash was never called.                     *)
  52.  
  53. END FinalExit.
  54.  
  55.