home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / mac / programm / 19690 < prev    next >
Encoding:
Internet Message Format  |  1992-12-11  |  1.5 KB

  1. Path: sparky!uunet!gumby!wupost!usc!davidp
  2. From: davidp@calvin.usc.edu (David Peterson)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: program exit (and entry) signals
  5. Date: 11 Dec 1992 14:35:09 -0800
  6. Organization: University of Southern California, Los Angeles, CA
  7. Lines: 23
  8. Distribution: world
  9. Message-ID: <1gb52tINNc30@calvin.usc.edu>
  10. Reply-To: davidp@usc.edu
  11. NNTP-Posting-Host: calvin.usc.edu
  12.  
  13.  
  14. Are there any signals you can get when your program starts up and when
  15. it exits? I'm not talking 'oapp' and 'quit' AppleEvents, I want something
  16. that gets called no matter how my program got started or how it shuts down.
  17.  
  18. I'm working on some library code and I can make the programmer call an 
  19. init routine before using the package, but making them call an 'uninit'
  20. routine seems rather ugly. Trouble is, my library needs to do some clean up
  21. when the program quits.
  22.  
  23. My officemate suggested patching _ExitToShell. Do people do this? Does this
  24. work? It seemed sort of heavy handed and rather obnoxious to me. I came up
  25. with the idea of making an object that consists only on a constructor and
  26. destructor. Both we're inlined and only called my init and cleanup routines
  27. respectively. By declaring a static instance of the object my init routine
  28. was called before entering 'main' and the cleanup was called after 'main' 
  29. had exited.
  30.  
  31. I haven't decided whether or not I like it though. Does anyone have any
  32. opinions about this? Did I completely miss something provided by the OS?
  33. Has somebody found a better way?
  34.  
  35. -dave.
  36.