[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Jumping back to REPL prompt on ^C

From: Neil Jerram
Subject: Re: Jumping back to REPL prompt on ^C
Date: Sun, 04 Jul 2010 21:52:19 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Taylor Venable <address@hidden> writes:

> Hi there, I'm writing a piece of code with a web server component, and
> part of that being that I want to jump back to the REPL when one hits
> ^C.  So it would go something like this:
> scheme@(guile-user)> (start-server)
> ;;; handling requests
> ^C
> scheme@(guile-user)>
> What I tried doing was essentially this:
> (call/cc (lambda (k) (sigaction SIGINT (lambda (_) (k))) (start-server)))

Just a couple of notes here.

First, continuations usually take an argument: the value which will be
the return value of the (call/cc ...) expression.  So '(k)' may be

Second, I wonder if you meant (lambda _ ...) instead of (lambda (_)
...).  I often use the former when I want a lambda that accepts any
number of arguments.

> Except *sometimes* when I hit ^C I ended up with an error that stops
> the guile program completely, seemingly due to the readline library
> that I've enabled in the REPL.  When I simplify my test I'm able to
> get the same fatal error all the time.
> In unknown file:
>    ?: 0 [catch-closure misc-error "%readline" "readline is not reentrant" () 
> #f]

This suggests to me that the code was already inside readline when you
hit ^C.

Does (start-server) ever return naturally?  If it does, there's a window
where it's just returned and the REPL is calling readline to read the
next line of input, but the terminal may not have shown the prompt yet.
So if you type ^C in that window, the error above would be expected.

Alternatively, does the code inside (start-server) ever use readline?
Perhaps by mistake it is using '(readline)' instead of '(read-line)'
from (ice-9 rdelim)?  In this case there'd obviously be loads more
chances of seeing the above error.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]