From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: vimml@selgrad.org Newsgroups: gmane.lisp.guile.user Subject: scm_shell in C-Thread - Quit vs. Terminal Corruption Date: Fri, 16 Oct 2009 21:09:25 +0200 Message-ID: <20091016190925.GA26534@shoikan> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1255747032 16373 80.91.229.12 (17 Oct 2009 02:37:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 17 Oct 2009 02:37:12 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sat Oct 17 04:37:02 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 1MyzAC-0000Ab-CW for guile-user@m.gmane.org; Sat, 17 Oct 2009 04:37:00 +0200 Original-Received: from localhost ([127.0.0.1]:38333 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MyzAB-0003PT-Uq for guile-user@m.gmane.org; Fri, 16 Oct 2009 22:36:59 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MysBE-0000wp-TY for guile-user@gnu.org; Fri, 16 Oct 2009 15:09:36 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MysBA-0000uU-E8 for guile-user@gnu.org; Fri, 16 Oct 2009 15:09:35 -0400 Original-Received: from [199.232.76.173] (port=54648 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MysB9-0000uR-BB for guile-user@gnu.org; Fri, 16 Oct 2009 15:09:31 -0400 Original-Received: from smtprelay01.ispgateway.de ([80.67.18.13]:46240) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MysB8-0002t1-SM for guile-user@gnu.org; Fri, 16 Oct 2009 15:09:31 -0400 Original-Received: from [84.56.75.3] (helo=localhost) by smtprelay01.ispgateway.de with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.68) (envelope-from ) id 1MysB4-0003Qi-DE for guile-user@gnu.org; Fri, 16 Oct 2009 21:09:26 +0200 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-Df-Sender: 1039925 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-Mailman-Approved-At: Fri, 16 Oct 2009 22:36:55 -0400 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:7441 Archived-At: Hi Schemers! I'm rather new to using guile, so please pardon if my question is more trivial than I think it is :) I have a graphics application (OpenGL) that spawns a thread which executes scm_shell(). This way I can use the terminal to query various information about the rendering. The program is usually exited by pressing in the graphics window. I found that I am unable to cleanly terminate both threads (acutal application and guile). When I enter (quit) in the terminal scm_shell calls exit(), which does not care much for my application cleanup. When I press the guile thread get aborted when the application terminates. To couple the guile-thread with the termination of my program I came up with starting a new thread in my scheme initialization which checks if the scheme-side should terminate. The pattern is shown in the following code, typed into the guile interpreter: guile> (define other-thread-wants-to-quit #f) guile> (define (my-thread) (if other-thread-wants-to-quit (begin (display "going home")(newline)(quit))) (sleep 1) (my-thread)) guile> (call-with-new-thread my-thread) guile> (set! other-thread-wants-to-quit #t) guile> going home When I run this it terminates the guile session, but also destroys my terminal. After guile returned the prompt is visible, but the characters thereafter are black on black, and hitting return does not break the current line. Hm, hard to describe, look at this: Hitting return three times yields: shellprompt ~ $ shellprompt ~ $ shellprompt ~ $ To summarize, my questions are: - Is there a better way to tell the scheme-thread to terminate? - Why does the code given above mess with my terminal? - What can I do to avoid it? Thanks in advace, and have a nice weekend :) Kai