guile-user
[Top][All Lists]
Advanced

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

Jumping back to REPL prompt on ^C


From: Taylor Venable
Subject: Jumping back to REPL prompt on ^C
Date: Sun, 20 Jun 2010 19:15:56 -0400

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

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.

scheme@(guile-user)> (call/cc (lambda (k) (sigaction SIGINT (lambda (_) (k)))))
(#<procedure 1e04720 at ice-9/boot-9.scm:3422:34 (sig)> . 67108864)
scheme@(guile-user)> Backtrace:
In ice-9/boot-9.scm:
 170: 12 [catch #t #<catch-closure 1ad8900> ...]
In unknown file:
   ?: 11 [catch-closure]
In ice-9/boot-9.scm:
  62: 10 [call-with-prompt prompt0 ...]
3437: 9 [top-repl]
In system/repl/repl.scm:
 105: 8 [start-repl scheme #:level 0 #:welcome #t]
 110: 7 [next-char #f]
In unknown file:
   ?: 6 [peek-char #<undefined>]
In ice-9/buffered-input.scm:
  72: 5 [get-character]
 107: 4 [#<procedure 1ee1100 at ice-9/buffered-input.scm:105:28
(continuation?)> #f]
In ice-9/eval.scm:
 374: 3 [eval # #]
In unknown file:
   ?: 2 [%readline "" #<input: standard input /dev/pts/2> ...]
In ice-9/boot-9.scm:
 115: 1 [#<procedure 1c4eca8 at ice-9/boot-9.scm:109:6 (thrown-k .
args)> misc-error ...]
In unknown file:
   ?: 0 [catch-closure misc-error "%readline" "readline is not reentrant" () #f]

ERROR: In procedure %readline:
ERROR: readline is not reentrant

After the error my terminal is left without key echoing enabled.  Is
there a way to accomplish what I'm trying to do?  Perhaps I simply
cannot do this with readline support enabled?  I'm not quite skilled
enough to figure out if my method is even a sensible way to try to get
it, or maybe I've violated something important by trying to invoke the
current continuation at the REPL.  I'm using Guile 2.0 from git,
commit 8d10ccae79ff46f0ebea92ba36acfaebafba8d86 on Linux x86_64.

Thanks for any ideas or explanation,

-- 
Taylor C. Venable
http://metasyntax.net/



reply via email to

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