From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: mark.d.witmer@gmail.com Newsgroups: gmane.lisp.guile.user Subject: Re: A timely question on interrupted system calls Date: Thu, 11 Jul 2013 21:26:21 -0700 Message-ID: <87ppuojtea.fsf@mark-desktop.PK5001Z> References: <87zjttk32l.fsf@mark-desktop.PK5001Z> <87ppupe1vg.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1373641950 32578 80.91.229.3 (12 Jul 2013 15:12:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 12 Jul 2013 15:12:30 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Fri Jul 12 17:12:31 2013 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Uxf1K-0006sb-GH for guile-user@m.gmane.org; Fri, 12 Jul 2013 17:12:30 +0200 Original-Received: from localhost ([::1]:35148 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uxf1K-0007YZ-2Q for guile-user@m.gmane.org; Fri, 12 Jul 2013 11:12:30 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36327) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UxUzg-0005lK-Gd for guile-user@gnu.org; Fri, 12 Jul 2013 00:30:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UxUzd-0001J2-Ht for guile-user@gnu.org; Fri, 12 Jul 2013 00:30:08 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:36239) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UxUzd-0001Fq-CD for guile-user@gnu.org; Fri, 12 Jul 2013 00:30:05 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UxUzb-0000m1-9K for guile-user@gnu.org; Fri, 12 Jul 2013 06:30:03 +0200 Original-Received: from 174-21-131-23.tukw.qwest.net ([174.21.131.23]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 12 Jul 2013 06:30:03 +0200 Original-Received: from mark.d.witmer by 174-21-131-23.tukw.qwest.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 12 Jul 2013 06:30:03 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 52 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 174-21-131-23.tukw.qwest.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:3uWXSDnKdLp72X/YS3MpGqVbo6w= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-Mailman-Approved-At: Fri, 12 Jul 2013 11:12:13 -0400 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:10521 Archived-At: ludo@gnu.org (Ludovic Courtès) writes: > mark.d.witmer@gmail.com skribis: > >> I followed the thread a few days ago on @guile-dev about SCM_SYSCALL and >> was grateful I hadn't run into any problems with it. But now I have! > > Excellent. :-) > >> I'm working with an event loop for my X bindings that polls a socket for >> availablity using `select'. Meanwhile, I have a repl server running in >> another thread. When something connects to the server, the call to >> `select' get interrupted and throws a system error. In the following >> code the catch expression doesn't catch the system error: > > Could it be that it’s actually the other thread that gets EINTR? Thanks for the insights. I figured out what I was doing wrong... it was actually a result of my not understanding dynamic states well enough. I had some parameters in use in the main thread that I wanted to share with the repl thread, so I figured it wouldn't hurt to do something like this: (define dynamic-state (current-dynamic-state)) (with-dynamic-state dynamic-state (make-thread (lambda () ... start repl ...))) But of course that was the cause of all my problems. The tag that `throw' uses when it aborts to the catch prompt is captured as an argument to a function stored in a fluid, so it's sensitive to manipulations of the dynamic state like this. Basically, the system error was throwing to a different (make-prompt-tag "catch") than the (make-prompt-tag "catch") my catch was set up to handle. D'oh! It didn't really have much to do with system calls or errors at all. I think the correct way to make parameters in different threads refer to the same object is like this: (define my-param-value (my-param)) (make-thread (lambda () (parameterize ((my-param my-param-value)) ...))) It feels a bit hackish, but sometimes I like the nested dynamic scope behavior of parameters even when I don't want the thread sandboxing. -- Mark Witmer