Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!caip!elbereth!rutgers!seismo!mcvax!unido!uklirb!mdoerr From: mdoerr@uklirb.UUCP Newsgroups: net.micro.atari16 Subject: Interrupt running programs - (nf) Message-ID: <14600008@uklirb.UUCP> Date: Fri, 10-Oct-86 09:14:00 EDT Article-I.D.: uklirb.14600008 Posted: Fri Oct 10 09:14:00 1986 Date-Received: Sun, 12-Oct-86 13:38:44 EDT Lines: 245 Nf-ID: #N:uklirb:14600008:000:9300 Nf-From: uklirb!mdoerr Oct 10 14:14:00 1986 Ask > Challenge: can anybody devise a way to stop a running program that does > not do any I/O (i.e. does not respond to ctrl-C), but WITHOUT rebooting!? > (I currently embed calls to keybrk() here and there in my loops, where > keybrk() is just a call to GEMDOS to see if ctrl-C was pressed, and an exit() > if it was... - that works but is ugly!) - I would like some program that > responds to an interrupt (say the alt-Help) and stops the currently running > application, in a clean way (no crashes or reboots, ability to do it > repeatedly in a session). I would like this ditty to be a separate program > that you run once and then it sits resident in RAM. I have tried such > a thing, with the interrupt handler doing an RTE to itself and then calling > gemdos(0) - but I get mysterious crashes after a few uses! Any ideas? > > - Moshe Braner and thou shall receive: WATCHER is another goodie from the Happy-Computer PD-Disk (remember MONST). It should work as follows: If your program gets stuck in an endless loop then press 3 times CTRL-B and once CTRL-C The executable has been UUENCODED on the ST. The source is for assembly language adventurers. As an additional bonus I've thrown in TBUG.PRG. Place multiple copies of it into the AUTO folder of your best friend and watch his/her eyes fall out. Have fun, but don't flame me! Michael Doerr Uni. of Kaiserslautern (Germany) uucp: ...!seismo!unido!uklirb!mdoerr ----------------- This is NO shell archive ------------------ begin 777 WATCHER.PRG M8!H %2 "@ !@ "!O 0L/ 0#0 !%9"04JP$ !G"%A!LD!F]$YU(_D M !P !9"/\ B '!%\! )+P "63G4CSP 6@O.0 61.=2!Y M !:# 0P'P@ &<"3G5"N0 7 @>0 6 B: ,B@ !#0H 8V* (. ,Z M K9"9@).=6X$. %91 PQ )0 V8&4KD %P6$6X16SLMD)N&$)%. ,,,0 " M4 -F!E*Y !<%A%N$5L[ RY P 7!L DYU('D %H(^@ @ 6PA M? 2@ DYU+SD %L2.?@X"\\ !4C\\ I.05R/2CD %39P9,WP<' I3G5"9TY!" !@2!A N!@X(!@@0!BX<$ H(!@H*#@!, end --------------- Cut Here --------------------------------- begin 777 TBUG.PRG M8!H +V $*G/SP ($Y!7(\CP @A( MY__^82),WW__+SD ((/SP ($Y!7(\_/ +SP /H/SP ,4Y!('D 16 M(^@ ! @Q#^0 (8A20 $0?D )*(\@ (^0?D *&(\@ )",#D M 2\ H #^(\ (8(_P "1DYU0H 0.0#_@@'A@- Y /^" ^& M(\ (<(#D (0 CXD>0 D)A #H80 !($* $#D _X(###D P #_@@-L$-"\ 0+ Y M /^"!VSX8!RP.0#_@@=O[M"\ 0,"\ _[ Y /^"!VSX(#D (0 @RQ_ M !G DZ03G4 M P?F?;R9F!6I$8MUKI&( M%:@1BW_^C; 'X / 8# &?@/;X9F96HT8AUKA&)%:C1B'_^#;$'X / 8 M P?F?_R?^!_Y'_M__I_X'_@?^W_^C_ 'X / 8# &?@/_X?^9_XW_A__A_Y M'_C?^'_^#_$'X / 8 H0RD@3RX@2F]P<&EC:"P@06T@2&]N:6=B;&5E:R Q M-"P@,S,P,"!" User-Mode rts * unterbrochenes Programm war im Super- * * visor Mode; nicht abbrechen * unterbrochenes Programm ist im User-Mode; XBIOS Tastaturpuffer * nach CTRL-B durchsuchen: continue clr.l count * Zaehler init. move.l iorecp,a0 * Adr. Pufferbeschreibungsblock move.l ibuf(a0),a1 * Adr. Tastaturpuffer move isize(a0),d1 * Puffergroesse (in bytes) move ihd(a0),d2 * Ringpuffer Anfang (Index) move itail(a0),d3 * Ringpuffer Ende (Index) move d3,d4 * D4: Ende fuer erste Schleife move d2,d5 * D5: Laufvariable cmp d2,d3 * Testen ob Puffer leer bne cont2 * nicht leer rts * leer; cont2 bgt nowrap * nur eine Schleife move d1,d4 * 2 Schleifen; erste bis Puffergroesse... subq #4,d4 * ...-4 nowrap cmp.b #ctrl_b,3(a1,d5) * CTRL-B im Puffer? bne cont3 * nein addq.l #1,count * zaehlen cont3 addq #4,d5 * naechster Index cmp d5,d4 * Ende erreicht? bge nowrap * Nein, weiter cmp d2,d3 * Test ob 2 Schleifen bgt ende * nein, fertig mit Durchsuchen clr d5 * Schleife 2 von 0 bis... move d3,d4 * ...Ende Index loop3 cmp.b #ctrl_b,3(a1,d5) * Schleife wie oben bne cont4 addq.l #1,count cont4 addq #4,d5 cmp d5,d4 bge loop3 * Schleifenende ende cmp.l #3,count * mindestens 3 mal CTRL-B gefunden? bge kill * ja, kill'em all rts * sonst normaler Ruecksprung * Ruecksprung des unterbrochenen Programms umleiten: kill move.l merksp,a0 * Interrupt Stackpointer move.l 2(a0),merkpc * Original-Ruecksprungadresse merken move.l #abort,2(a0) * neue Ruecksprungadr. dafuer eintragen rts * Ende VBL-Routine * An diese Stelle wird der Ruecksprung des unterbrochenen Programms * umgeleitet, falls 3 mal CTRL-B im Tastaturpuffer gefunden wurde abort move.l merkpc,-(sp) * Original-Ruecksprungadresse movem.l d0-d2/a0-a2,-(sp) * Register retten move.l #ibuff,-(sp) * Eingabezeile lesen move #readline,-(sp) trap #gemdos addq.l #6,sp tst.b ibuff+1 * Eingabe da? beq exit * Nein, vermutlich EOF bei Input Redirection movem.l (sp)+,d0-d2/a0-a2 * ansonsten Programm fortsetzen rts exit clr -(sp) trap #gemdos .data ibuff .dc.b 8,0 .ds.b 8 .end ------------------ This Is The End ----------------------------