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: A timely question on interrupted system calls Date: Wed, 10 Jul 2013 23:45:06 -0700 Message-ID: <87zjttk32l.fsf@mark-desktop.PK5001Z> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1373525070 3119 80.91.229.3 (11 Jul 2013 06:44:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 11 Jul 2013 06:44:30 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Thu Jul 11 08:44:30 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 1UxAcA-00047Q-6y for guile-user@m.gmane.org; Thu, 11 Jul 2013 08:44:30 +0200 Original-Received: from localhost ([::1]:37390 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UxAc9-0007Xp-NI for guile-user@m.gmane.org; Thu, 11 Jul 2013 02:44:29 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40927) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UxAbz-0007XY-B6 for guile-user@gnu.org; Thu, 11 Jul 2013 02:44:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UxAbw-0001kX-Gs for guile-user@gnu.org; Thu, 11 Jul 2013 02:44:19 -0400 Original-Received: from mail-pd0-x235.google.com ([2607:f8b0:400e:c02::235]:37143) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UxAbw-0001kP-9r for guile-user@gnu.org; Thu, 11 Jul 2013 02:44:16 -0400 Original-Received: by mail-pd0-f181.google.com with SMTP id 14so7205859pdj.12 for ; Wed, 10 Jul 2013 23:44:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:user-agent:mime-version :content-type; bh=YqORqIsWAT95cirjRmP4NkgMLJvPA+slDXGLVHycn08=; b=LvgXMZrb1JkCILgFhGq1TmlSmCI61/9z2bop00gmVmJvmvOYOOY73cZ+XLdyZrU0Sc cucUeHJiAr8Vr09scQnkrdMijGO/T3UzSg+zQ9epumJNSERLXaVIe7tsquKFNunasxYM Snc1xuO+nGYXEOlA7rL3oP7kMekMs7nOlp53FW1V8Gj5oya+SASezLQ3Cr6c/ulAE+J1 uP+klyYkoPSJkOmO2IIZ5SfZ8tGs5Iy4JY0Xu2Lke2S1e/IF7wOh5ddLCrdQ9Z5e7DmW pIEW1v+izepJHCk2sTxvzwsyEHjwqFwLorotdKVRcpfXsSa9ZIpYtVm4MbEbfZwZIjIq ZTqg== X-Received: by 10.68.197.136 with SMTP id iu8mr34959961pbc.183.1373525055375; Wed, 10 Jul 2013 23:44:15 -0700 (PDT) Original-Received: from localhost (174-21-131-23.tukw.qwest.net. [174.21.131.23]) by mx.google.com with ESMTPSA id kc8sm37967824pbc.18.2013.07.10.23.44.13 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 10 Jul 2013 23:44:14 -0700 (PDT) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c02::235 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:10512 Archived-At: 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! 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: (define (file-ready? fd) (memq fd (car (catch 'system-error (lambda () (select (list fd) '() '() 0 16667)) (lambda args (if (= (system-error-errno args) EINTR) '(() () ()) ;; Assume it isn't available for now (apply throw args))))))) I gathered from what I read that the error is getting handled in a system async, which could explain why my catch expression doesn't see it. I also tried a couple versions of `sigaction' without any luck: (sigaction SIGINT (lambda (signum) #t) SA_RESTART) and (sigaction SIGINT #f SA_RESTART) It'd be fine if it automatically retried instead of returning the empty lists. Any ideas? -- Mark Witmer