guile-user
[Top][All Lists]
Advanced

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

Re: Jumping back to REPL prompt on ^C


From: Andy Wingo
Subject: Re: Jumping back to REPL prompt on ^C
Date: Thu, 08 Jul 2010 20:31:43 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

Hi Neil & Taylor,

On Sun 04 Jul 2010 21:52, Neil Jerram <address@hidden> writes:

> 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
> wrong.

Indeed, though the intention may be that an escape returns 0 values;
unlikely however.

> 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.

True, though sigaction handlers do get called with only one argument.

>> 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]

You know, I've seen this on a couple occaisions. If you can find out how
to reproduce this I would be very interested.

In the future you should be able to just return to the prompt on SIGINT
by setting a REPL option. Dunno if that works for Taylor, though...

Andy
-- 
http://wingolog.org/



reply via email to

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