schwager@m.cs.uiuc.edu (07/21/88)
I'm a Unix kind of guy, so I'm always disappointed during this scenario: I'm on my Amiga, learning to program in C (my first project is an Amiga version of the Unix expand(1) command), and I manage to program an infinite loop, or use a pointer incorrectly, or something. Anyway, the machine hangs... it's still alive, but the program is spinning endlessly. So what I want to do is hit a control-C to stop it, ala Unix. I want to generate a chunk of code, a "generic control-C recognizer" if you will, that I can include in all my code so that I can stop it if I want. I read in the Manx 3.4 manual about a function called Chk_Abort (this is in libov68, page 4), but I wasn't able to find any hard facts about this function. It's not in Manx' index, it's not in the Amiga Reference Manuals, nothin'. Is this possible to do? Somehow, my intellect says no, but my heart wants to believe... -Mike Schwager -- {uunet,convex,pur-ee}!uiucdcs!schwager schwager%uiuc@csnet-relay.arpa schwager@cs.uiuc.edu University of Illinois, Dept. of Computer Science P.S. Send E-mail on this, please... I've been so busy at work, I've nary a moment for reading comp.sys.amiga :-(
blandy@marduk.cs.cornell.edu (Jim Blandy) (07/21/88)
Let's see - I'm curious about this question too, so I'll post my theories in hopes of a correction... If you're running a program in a CLI, pressing ^C in the CLI window sends a signal to the foreground process that CLI is running. You can use the BREAK command to send signals to programs running under other CLIs (i.e. background CLIs that don't have their own window). The signal number that ^C uses is #defined in <libraries/dos.h> as SIGBREAKB_CTRL_C. (For ONCE, I've got my manual nearby while I'm reading news! HAH! Hmm. "Copyright 1985... rev 2" Yuck.) Note that ^D, ^E, and ^F also send their own signals. Okay - how to recognize the signals once you've set them: you can poll the signals directly (using the SetSignal() routine from the Exec library), which tells you the current state of the signals. But you want something asynchronous, I think. You can ask the system to cause an exception on receipt of a signal - this means that you set tc_ExceptCode (in your task structure) to point to a routine to call in the event of the signal, and then call the SetExcept() routine (also in Exec) to indicate that certain signals should cause exceptions. Exec saves your processor state on the stack and all that neat stuff, and passes you some information in D0 and A0 - exception handlers probably want to be in assembly language. This is where I get lost. What am I allowed to do in this exception? Can I call exit()? I suppose one should restore the original contents of the tc_ExceptCode field for the CLI, since we're sharing a process, right? I've tried some variation on this before, and it's always crashed. ...helphelpplehpleh... -- Jim Blandy - blandy@crnlcs.bitnet "insects were insects when man was just a burbling whatisit." - archy
wayne@utflis.UUCP (Wayne Young) (07/25/88)
I thought this would have been answered by now, but since it hasn't.... If you look around in some of the earlier Fish disks, you'll find a little gem that Fred wrote himself. It's a cc command for Lattice, and it comes with sources. There's some code in it which checks for ^C, and you can easily extract the necessary stuff to make your own check_abort() routine. -- ----- {uunet,utzoo,decvax,allegra}!utcsri!utflis!wayne