Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!cuae2!ihnp4!drutx!mtuxo!tas From: tas@mtuxo.UUCP (t.skrobala) Newsgroups: net.micro.amiga,comp.sys.amiga Subject: Capturing ^C Message-ID: <2210@mtuxo.UUCP> Date: Thu, 6-Nov-86 08:37:56 EST Article-I.D.: mtuxo.2210 Posted: Thu Nov 6 08:37:56 1986 Date-Received: Fri, 7-Nov-86 22:44:05 EST Distribution: na Organization: AT&T Information Systems Labs, Holmdel NJ Lines: 75 Xref: watmath net.micro.amiga:5751 comp.sys.amiga:1 ...Throw me a line... 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. If I explicitly call signal(task, SIGBREAKF_CTRL_C), onintr() *does* get called. If I don't call SetExcept(), ^C produces an immediate exit (after I hit RETURN to satisfy the read()). I know that it's possible to check for ^C with SetSignal() after every read(), but I'm hoping that there's a less burdensome way to detect the exception. I am using Manx Aztec C with 1.1 Amiga software. Thanks, Tom Skrobala AT&T Information Systems ihnp4!ariel!tas -------------------------------------------------------------- #include #include #include #include #include long exceptID ; long hadIntr ; #asm public _onintr _onintr: or.l d0,_exceptID add.l #1,_hadIntr rts #endasm extern onintr() ; main() { struct Task *task ; long oldSignals ; char buf[10] ; int n ; exceptID = 0 ; hadIntr = 0 ; task = FindTask( NULL ) ; printf( "task=0x%lx\n", task ) ; task->tc_ExceptCode = (APTR)onintr ; oldSignals = SetExcept( SIGBREAKF_CTRL_C, SIGBREAKF_CTRL_C ) ; while( n = read( 0, buf, 10 ), buf[0] != 'x' ) { if( exceptID || hadIntr ) { printf( "received %ld signal(s) 0x%lx\n", hadIntr, exceptID ) ; exceptID = 0 ; hadIntr = 0 ; } printf( "received n=%d, %c\n", n, buf[0] ) ; if( n < 0 ) printf( "received err=%ld\n", IoErr() ) ; } printf( "out of loop\n" ) ; }