[gambit-list] Interrupted in wait-for-io

Marc Feeley feeley at iro.umontreal.ca
Tue Jan 3 10:18:23 EST 2006


CTRL-C does not generate an exception.  It simply calls the current  
user-interrupt-handler. What you want is this:

(current-user-interrupt-handler
   (lambda () (display "goodbye!\n") (exit)))

(with-exception-catcher
  (lambda (e)
    (display "Catched an exception: ")
    (write e)
    (newline)
    (##repl))
  (lambda ()
    (read)))

Note that the REPL dynamically binds its own user-interrupt-handler  
for the dynamic extent of the call to ##repl (in other words, once  
you get a REPL you are debugging and a CTRL-C is either ignored when  
reading the expression to evaluate or is interpreted as a desire to  
interrupt the evaluation and go back to the REPL).

Marc

On 3-Jan-06, at 9:15 AM, Christian wrote:

> Hello
>
> Why aren't interrupts (ctl-c in particular) running the current
> exception handler, but instead enter the debugger unconditionally?
>
> $ cat testinterrupt.scm
> (with-exception-catcher
>  (lambda (e)
>    (display "Catched an exception: ")
>    (write e)
>    (newline)
>    (##repl))
>  (lambda ()
>    (read)))
>
> $ gsi
>> (load "testinterrupt.scm")
> *** INTERRUPTED IN ##wait-for-io!
> 1> fooo
> Catched an exception: #<unbound-global-exception #2>
> 1> foo
> *** ERROR IN (console)@3.1 -- Unbound variable: foo
> 2>
>
> Note that inside the debugger, my exception handler is still active,
> as shown after entering |fooo|. So it's not that ##wait-for-io or some
> other function would install another handler, but that the
> current-exception-handler is simply ignored.
>
> Same thing in compiled code, except that there's no handler catching
> exceptions when inside mine:
>
> $ gsc -warnings testinterrupt
> $ gcc -O3 -fomit-frame-pointer -mpreferred-stack-boundary=2 - 
> Wdisabled-optimization testinterrupt.c testinterrupt_.c -I/usr/ 
> local/Gambit-C/include -L/usr/local/Gambit-C/lib -lgambc -lm -lutil  
> -ldl -o testinterrupt
>
> $ ./testinterrupt
> *** INTERRUPTED IN ##wait-for-io!
>> foo
> Catched an exception: #<unbound-global-exception #2>
>> foo
> *** ERROR IN (console)@2.1 -- Unbound variable: foo
> $
>
> The real problem with this is: how can I create a standalone Gambit
> program that exits when it gets SIGINT ?
>
> Thanks
> Christian.
>
> _______________________________________________
> Gambit-list mailing list
> Gambit-list at iro.umontreal.ca
> http://mailman.iro.umontreal.ca/mailman/listinfo/gambit-list




More information about the Gambit-list mailing list