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