From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Neil Jerram Newsgroups: gmane.lisp.guile.user Subject: Re: Jumping back to REPL prompt on ^C Date: Sun, 04 Jul 2010 21:52:19 +0100 Message-ID: <87vd8vq8ak.fsf@ossau.uklinux.net> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1278276762 1761 80.91.229.12 (4 Jul 2010 20:52:42 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 4 Jul 2010 20:52:42 +0000 (UTC) Cc: guile-user@gnu.org To: Taylor Venable Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sun Jul 04 22:52:40 2010 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OVWB5-0003Sz-Nk for guile-user@m.gmane.org; Sun, 04 Jul 2010 22:52:40 +0200 Original-Received: from localhost ([127.0.0.1]:46245 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OVWB5-0000tz-46 for guile-user@m.gmane.org; Sun, 04 Jul 2010 16:52:39 -0400 Original-Received: from [140.186.70.92] (port=60840 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OVWAp-0000rI-Gp for guile-user@gnu.org; Sun, 04 Jul 2010 16:52:24 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OVWAo-0002RC-8Z for guile-user@gnu.org; Sun, 04 Jul 2010 16:52:23 -0400 Original-Received: from mail3.uklinux.net ([80.84.72.33]:33120) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OVWAo-0002R1-4I for guile-user@gnu.org; Sun, 04 Jul 2010 16:52:22 -0400 Original-Received: from arudy (unknown [92.29.72.223]) by mail3.uklinux.net (Postfix) with ESMTP id CA8551F6A70; Sun, 4 Jul 2010 21:52:20 +0100 (BST) Original-Received: from arudy (unknown [192.168.11.8]) by arudy (Postfix) with ESMTP id 211DD3801D; Sun, 4 Jul 2010 21:52:20 +0100 (BST) In-Reply-To: (Taylor Venable's message of "Sun, 20 Jun 2010 19:15:56 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:7953 Archived-At: Taylor Venable 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