unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Neil Jerram <neil@ossau.uklinux.net>
To: Taylor Venable <taylor@metasyntax.net>
Cc: guile-user@gnu.org
Subject: Re: Jumping back to REPL prompt on ^C
Date: Sun, 04 Jul 2010 21:52:19 +0100	[thread overview]
Message-ID: <87vd8vq8ak.fsf@ossau.uklinux.net> (raw)
In-Reply-To: <AANLkTilwUoHrUxZyDH7rQAH-Bq1K6yzvpyVt8QB6B4Rj@mail.gmail.com> (Taylor Venable's message of "Sun, 20 Jun 2010 19:15:56 -0400")

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.

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.

Regards,
     Neil



  reply	other threads:[~2010-07-04 20:52 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 [this message]
2010-07-08 19:31   ` Andy Wingo
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=87vd8vq8ak.fsf@ossau.uklinux.net \
    --to=neil@ossau.uklinux.net \
    --cc=guile-user@gnu.org \
    --cc=taylor@metasyntax.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).