[comp.sys.mac.programmer] Crash recovery under MultiFinder

dunlop@cs.glasgow.ac.uk (Mark Dunlop) (02/02/90)

Once upon a time I wrote an application which used the `hook' from the
Resume button in the System Error dialogue box to do some recovery. This
worked very nicely, I attempted to do the same again under MultiFinder
but all I get is the MultiFinder dialgue box stating the the application 
unexpectedly quit. Is there any way to (maybe a flag somewhere) tell the system 
to give me the good ole System Error dialogue rather than the MultiFinder 
getting its paws on it and mucking up any crash recovery? It's not that my 
application crashes all the time, I've just not proven it correct so I assume 
the worst might happen one day and would like the users not to beat me up
when if happens....


Mark
-- 
Mail:  Mark Dunlop, Department of Computing Science, 
       University Of Glasgow, Glasgow G12 8QQ, Scotland, UK.
ARPA:  dunlop%cs.glasgow.ac.uk@nsfnet-relay.ac.uk USENET: dunlop@cs.glasgow.uucp

cc100aa@prism.gatech.EDU (Ray Spalding) (02/07/90)

In article <4413@vanuata.cs.glasgow.ac.uk> dunlop@cs.glasgow.ac.uk (Mark Dunlop) writes:
>[...] Is there any way to [...] tell the system 
>to give me the good ole System Error dialogue rather than the MultiFinder 
>getting its paws on it and mucking up any crash recovery? [...]

I asked a similar question a few months back, and the best answer I
got was to patch ExitToShell().  This seems to work well under both
Multi- and Unifinder.  But note that your patch gets control under
normal exit conditions as well as error conditions (unless you un-patch
before exiting).

The code I'm using (MPW C) looks like the following; perhaps someone
more familiar with patching could comment if there are any potential
problems with this code.

#include <Segload.h>
#include <Traps.h>
#include <OSUtils.h>
pascal void resume_proc();
long sysExit;
main() {
	/* ... */
	sysExit = NGetTrapAddress(_ExitToShell,ToolTrap);
	NSetTrapAddress((long)resume_proc,_ExitToShell,ToolTrap);
	/* ... */
}
pascal void resume_proc()
{
	if (sysExit) {
		NSetTrapAddress(sysExit,_ExitToShell,ToolTrap);
	}
	/* clean up my mess ... */
	ExitToShell();
}

-- 
Ray Spalding, Office of Computing Services
Georgia Institute of Technology, Atlanta Georgia, 30332-0275
uucp:     ...!{allegra,amd,hplabs,ut-ngp}!gatech!prism!cc100aa
Internet: cc100aa@prism.gatech.edu