[comp.sys.mac] Detecting Quits.

betz@runx.ips.oz (Andrew Betzis) (04/30/87)

	Nosy-ing the following three programmes, the following ways were used to
detect applications quiting, all reassigned traps:

		SkipFinder (DA) = BlockMove (detected a BlockMove of FinderName -> CurAppName
).

		Locator (DA) = ExitToShell

		Launch (FKEY) = CloseResFile (detected when refNum = CurApRefNum)

	The question is: Is there a standard way of detecting Application exits ?

	The root of the problem is to be able to re-Trap quits.

Smile & Thanks,
Andrew Betzis.


ACSnet: betz@runx.ips.oz		JANET:	runx.ips.oz!betz@ukc
ARPA:   betz%runx.ips.oz@seismo.css.gov	CSNET:	betz@runx.ips.oz
UUCP:  {enea,hplabs,mcvax,prlb2,seismo,ubc-vision,ukc}!munnari!runx.ips.oz!betz

jww@sdcsvax.UCSD.EDU (Joel West) (05/04/87)

In article <850@runx.ips.oz>, betz@runx.ips.oz (Andrew Betzis) writes:
> 
> 	Nosy-ing the following three programmes, the following ways were used to
> detect applications quiting, all reassigned traps:
> 		Locator (DA) = ExitToShell

I don't know what these programs are doing.  They're all wrong.

The right way is to look for a DRVRControl call of goodBye (-1),
the so-called "goodbye kiss".  Set the block in the 'DRVR' header
needGoodbye.  This is all well-documented in Inside Macintosh.
-- 
	Joel West
	{ucbvax,ihnp4}!sdcsvax!jww	(ihnp4!gould9!joel if I ever fix news)
	jww@sdcsvax.ucsd.edu	if you must

awd@ut-ngp.UUCP (Darin Adler) (05/05/87)

In article <850@runx.ips.oz>, betz@runx.ips.oz (Andrew Betzis) writes:
>SkipFinder (DA) = BlockMove (detected a BlockMove of FinderName -> CurAppName)
>Locator (DA) = ExitToShell
>Launch (FKEY) = CloseResFile (detected when refNum = CurApRefNum)

Early versions of SkipFinder used the BlockMove trap to catch exits to
the Finder.  Later, I switched to the "OpenResFile" trap.  This
technique is used by SkipFinder, Sequencer, the MiniFinder, and the
MPW Shell and is fairly stable.  The check is for an OpenResFile call,
from the ROM (return address > ROMBase), with a file name that is the
same as "FinderName".  Once you detect what is going on, you can start
over with a new launch, or open a different resource file and continue.

Intercepting ExitToShell does not work in all cases.  Intercepting
BlockMove is stupid (it's called too often).  The only call to
OpenResFile that the ROM makes is from the Launch (and Chain) routine,
and this has never changed, in the Mac, Mac Plus, Mac SE, or Mac II
ROMs.

Of course, these days, it's smarter to read the new Apple Tech Note,
and do it with a call to SubLaunch.

By the way, contrary to what you might think, the new launch calls
will not make all the old transfer menus stop working.
--------
Darin Adler
"You can't reach me on UseNet."
AppleLink: D0144
GEnie: DADLER