From: Andy Wingo <wingo@pobox.com>
To: Neil Jerram <neil@ossau.uklinux.net>
Cc: guile-user@gnu.org
Subject: Re: Jumping back to REPL prompt on ^C
Date: Thu, 08 Jul 2010 20:31:43 +0100 [thread overview]
Message-ID: <m3fwztrcrk.fsf@unquote.localdomain> (raw)
In-Reply-To: <87vd8vq8ak.fsf@ossau.uklinux.net> (Neil Jerram's message of "Sun, 04 Jul 2010 21:52:19 +0100")
Hi Neil & Taylor,
On Sun 04 Jul 2010 21:52, Neil Jerram <neil@ossau.uklinux.net> writes:
> Taylor Venable <taylor@metasyntax.net> 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/
next prev parent reply other threads:[~2010-07-08 19:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-20 23:15 Jumping back to REPL prompt on ^C Taylor Venable
2010-07-04 20:52 ` Neil Jerram
2010-07-08 19:31 ` Andy Wingo [this message]
2010-07-09 15:57 ` Andy Wingo
2010-07-27 21:16 ` Taylor Venable
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3fwztrcrk.fsf@unquote.localdomain \
--to=wingo@pobox.com \
--cc=guile-user@gnu.org \
--cc=neil@ossau.uklinux.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).