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: scm_shell in C-Thread - Quit vs. Terminal Corruption Date: Sun, 18 Oct 2009 16:05:57 +0100 Message-ID: <87iqec7ne2.fsf@ossau.uklinux.net> References: <20091016190925.GA26534@shoikan> <3ae3aa420910161942y67d04163kb270dba9b05f61b3@mail.gmail.com> <20091017173618.GA5441@shoikan> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1255878418 8940 80.91.229.12 (18 Oct 2009 15:06:58 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 18 Oct 2009 15:06:58 +0000 (UTC) Cc: guile-user@gnu.org To: kai.selgrad@web.de Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sun Oct 18 17:06:48 2009 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.50) id 1MzXLL-0004Na-Se for guile-user@m.gmane.org; Sun, 18 Oct 2009 17:06:48 +0200 Original-Received: from localhost ([127.0.0.1]:44754 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MzXLL-0004AA-Fb for guile-user@m.gmane.org; Sun, 18 Oct 2009 11:06:47 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MzXLH-000483-98 for guile-user@gnu.org; Sun, 18 Oct 2009 11:06:43 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MzXLC-0003y6-CR for guile-user@gnu.org; Sun, 18 Oct 2009 11:06:42 -0400 Original-Received: from [199.232.76.173] (port=59647 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MzXLC-0003xl-8B for guile-user@gnu.org; Sun, 18 Oct 2009 11:06:38 -0400 Original-Received: from mail3.uklinux.net ([80.84.72.33]:43515) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MzXLB-0004yz-OF for guile-user@gnu.org; Sun, 18 Oct 2009 11:06:37 -0400 Original-Received: from arudy (host86-145-159-48.range86-145.btcentralplus.com [86.145.159.48]) by mail3.uklinux.net (Postfix) with ESMTP id EED1B1F6B1D; Sun, 18 Oct 2009 16:05:58 +0100 (BST) Original-Received: from arudy (arudy [127.0.0.1]) by arudy (Postfix) with ESMTP id 5C26538024; Sun, 18 Oct 2009 16:05:58 +0100 (BST) In-Reply-To: <20091017173618.GA5441@shoikan> (kai selgrad's message of "Sat, 17 Oct 2009 19:36:18 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) X-detected-operating-system: by monty-python.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:7455 Archived-At: kai.selgrad@web.de writes: > Hej linas, > > thanks for your reply. > >> > application and guile). When I enter >> > =A0 =A0 =A0 =A0(quit) >> > in the terminal scm_shell calls exit(), which does not care much for my >> > application cleanup. >> wouldn't atexit() solve this problem? > Yes, you're right. atexit() would solve this problem. Didn't really > think about that before... hm :) > Sadly, the otherway around is much more common (pressing ESC in the > application window, thus terminating the actual application thread). Calling scm_shell() with no args means just that that thread will run `(top-repl)' - whose definition you can see in boot-9.scm. In other words you could say that the default args are like `-c (top-repl)'. `(quit)' means (throw 'quit ...), and the (top-repl) code handles this by exiting its internal loop. Then scm_shell() calls exit(). So, if you want something else to happen after `(quit)', such as waiting for other threads to terminate and clean up, you just need to put code for that in a procedure named, e.g. `wait-for-cleanup', and then call scm_shell() with args `-c (begin (top-repl) (wait-for-cleanup)'. (All in theory anyway, I'm afraid I haven't tested this!) Neil