Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!rochester!cornell!uw-beaver!mit-eddie!genrad!decvax!ucbvax!hplabs!well!ewhac From: ewhac@well.UUCP (Leo 'Bols Ewhac' Schwab) Newsgroups: comp.sys.amiga Subject: Re: SetExcept() & exception code Message-ID: <3565@well.UUCP> Date: Wed, 15-Jul-87 16:42:38 EDT Article-I.D.: well.3565 Posted: Wed Jul 15 16:42:38 1987 Date-Received: Sat, 18-Jul-87 02:20:07 EDT References: <545@applix.UUCP> Reply-To: ewhac@well.UUCP (Leo 'Bols Ewhac' Schwab) Distribution: world Organization: Hole Earth 'Lectronic Loss (or words to that effect) Lines: 31 Summary: Exception routines *must* return unless you fiddle with the stack. In article <545@applix.UUCP> scott@applix.UUCP (Scott Evernden) writes: >I am trying to use SetExcept() to capture some keyboard signals. I >would like to know what, if any, are the problems associated with >longjmp()'ing out of the exception handling code. Is this legal? >Should it work? > Unlikely. When the exception vector gets called, *all processor registers* are pushed on the stack, and the exception handler is called. This means that, eventually, the stack may exhaust itself back to the register list on the stack. Also, if the exception routine itself ever manages to return back to the exception dispatcher, the dispatcher will attempt to reload the CPU registers with garbage. I tried using an exception handler to trap a ^C interrupt, and then clean up and exit. Part of exiting is flushing the stack. So all the cleanup code worked great, but when exit() got called, the stack got flushed, destroying the register list, and then tried to return to the DOS. Somewhere, a guru happened, and I didn't feel like massaging the stack to make it happen neatly. Sigh. I guess the moral is that exceptions should always return invisibly, and not try to do anything cute. I'll study this in more detail when the mood strikes me.... P.S: This is off the top of my head, and I'm not thinking too hard at the moment. Please forgive any inaccuracies... _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ Leo L. Schwab -- The Guy in The Cape ihnp4!ptsfa -\ \_ -_ Bike shrunk by popular demand, dual ---> !{well,unicom}!ewhac O----^o But it's still the only way to fly. hplabs / (pronounced "AE-wack") "Work FOR? I don't work FOR anybody! I'm just having fun." -- The Doctor