Article View: net.micro.amiga
Article #4966Re: Capturing ^C
From: Paul Higginbottom
Date: Sat, 08 Nov 1986 17:32
Date: Sat, 08 Nov 1986 17:32
86 lines
3529 bytes
3529 bytes
In article <46@uw-atm.UUCP> james@uw-atm.UUCP (James M Synge) writes:
>In article <2210@mtuxo.UUCP>, tas@mtuxo.UUCP (t.skrobala) writes:
>> Is there a way to capture ^C signals on Amiga in a manner analagous to
>> UNIX signal()? I'd like to be able to abort recalcitrant programs with
>> ^C, but do some cleanup before exiting. Thus I'd like a function to be
>> called when ^C is typed. My reading of the ROM Kernel Manual suggests
>> that SigExcept() is the key, but, in the example below, my onintr()
>> function only gets called once (with d0 set to 0), when SetExcept() is
>> called, and never thereafter; ^C's are ignored.
>
>I've tried writing an exception handler and had some problems. One thing
>I notice you're not dealing with in your assembly section is the fact that
>you don't know what state your registers are in, except D0 and A0, which
>contain the signal mask and address of your ExceptData. SO, when your
>code is adding 1 to hadIntr, you don't know where that 1 is being
>added. It is some offset from (A4), but, since A4 is in an unknown state,
>we don't know where that is.
>
This is not really true. The "rules" of the OS dictate that routines
leave registers untouched except d0/d1/a0/a1 which are used for passing
args and results and cannot be guaranteed to be munged during some call.
Thus, a4 should always be in a healthy state for a program's assembler
sections to access any variables in the C or assembler parts. The
linker converts:
move.w _stuff,d0
into
move.w (a4)_stuff,d0
(please excuse assembler inaccuracies, I do as little as possible)
>> If I don't
>> call SetExcept(), ^C produces an immediate exit (after I hit RETURN to
>> satisfy the read()).
>
>This is because the Manx io routines check for ^C every time (unless you
>set an external variable whose name I cann't remember).
>
The variable is Enable_Abort, and to disable Manx's checking of CTRL-C
during sys and std i/o - you need to set it to 0. E.g:
main()
{
extern short Enable_Abort;
Enable_Abort = 0; /* no more ctrl-c aborts */
...
}
However, you can STILL check for CTRL-C's conveniently via the Chk_Abort()
function provided in the Manx system. E.g:
...
extern long Chk_Abort();
... some i/o loop ...
{
if (Chk_Abort())
{
break; /* leave the loop */
}
....
}
... cleanup here ...
>> Thanks,
>> Tom Skrobala AT&T Information Systems ihnp4!ariel!tas
>
>My pleasure,
>--
>---------------------------------------------------------------------------
>James M Synge, Department of Atmospheric Sciences, University of Washington
>VOX: 1 206 543 0308 (Work) 1 206 455 2025 (Home)
>UUCP: uw-beaver!geops!uw-atm!james
>ARPA: geops!uw-atm!james@beaver.cs.washington.edu
Mine too,
Paul Higginbottom, my house, Exton, PA.
Disclaimer: I work for myself, and my opinions are my own.
Technical Details
Message-ID:
<971@cbmvax.cbmvax.commodore.COM>Path:
arc1-ca.pugleaf.net!utzoo!watmath!clyde!rutgers!cbmvax!higginReferences:
<2210@mtuxo.UUCP> <46@uw-atm.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!rutgers!cbmvax!higgin From: higgin@cbmvax.commodore.COM (Paul Higginbottom) Newsgroups: net.micro.amiga,comp.sys.amiga Subject: Re: Capturing ^C Message-ID: <971@cbmvax.cbmvax.commodore.COM> Date: Sat, 8-Nov-86 12:32:48 EST Article-I.D.: cbmvax.971 Posted: Sat Nov 8 12:32:48 1986 Date-Received: Sun, 9-Nov-86 05:39:39 EST References: <2210@mtuxo.UUCP> <46@uw-atm.UUCP> Reply-To: higgin@cbmvax.UUCP (Paul Higginbottom) Distribution: net Organization: PDH, Inc. Lines: 86 Summary: followup to James Synge's comments...