Article View: net.micro.atari16
Article #444Catching ^C and "mushrooms"
From: Landon Dyer
Date: Thu, 17 Apr 1986 19:33
Date: Thu, 17 Apr 1986 19:33
41 lines
2359 bytes
2359 bytes
> Does anybody know how to get control of the ^C handling? I would
> like to find some way to prevent my program from getting killed
> without giving it a chance to clean up. (It doesn't seem possible
> to keep a conin() request pending all the time, because, for
> instance, when you are in the middle of a long write() to a file
> you are sensitive to being killed). Clearly one should just not type
> ^C, but I would like to make my software "idiot proof".
You CAN catch ^C (as well as any other terminate). In the grand DRI
tradition, it is the usual monster kludge:
---------------- (excerpt)
0x102 Terminate (^C) Handler
Before a process is actually terminated, GEMDOS
calls the terminate vector. If the terminate vector
points to an RTS (the default case), the process will
be terminated. If the application does not wish to be
terminated it should do a longjump (or its equivalent)
to an appropriate handler.
----------------
This is extended vector 0x102, located at 0x408 in protected RAM.
The vector is called on ANY terminate (including function 0x00, Pterm0()).
It also catches the "mushroom" exceptions (bus errors, etc.). In actual
practice, about all you can do after a bus error is to clean up any
hanging data structures (vblank handlers, keyboard tables, RS232
buffers, etc.), RTS, and hope for the best.
One of the things you have to restore is the vector itself ....
^C is only checked for on cooked console input OR output. So if you
use purely BIOS calls, or just GEMDOS file I/O, you are safe. Also, raw
input from the console ignores ^C.
--
-Landon "If Business is War, then I'm a Prisoner of Business!"
... {hoptoad, lll-crg!vecpyr}!atari!dyer "Quantity is Quality"
Technical Details
Message-ID:
<197@atari.UUcp>Path:
arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!princeton!orsvax1!pyrnj!caip!lll-crg!lll-lcc!vecpyr!atari!dyerReferences:
<860409-150043-1731@Xerox> <3511@sun.uucp>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!princeton!orsvax1!pyrnj!caip!lll-crg!lll-lcc!vecpyr!atari!dyer From: dyer@atari.UUcp (Landon Dyer) Newsgroups: net.micro.atari16 Subject: Catching ^C and "mushrooms" Message-ID: <197@atari.UUcp> Date: Thu, 17-Apr-86 14:33:45 EST Article-I.D.: atari.197 Posted: Thu Apr 17 14:33:45 1986 Date-Received: Sun, 20-Apr-86 16:38:31 EST References: <860409-150043-1731@Xerox> <3511@sun.uucp> Organization: Atari Corp., Sunnyvale CA Lines: 41