From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Newsgroups: gmane.lisp.guile.user Subject: Re: A timely question on interrupted system calls Date: Thu, 11 Jul 2013 14:07:31 +0200 Message-ID: <87ppupe1vg.fsf@gnu.org> References: <87zjttk32l.fsf@mark-desktop.PK5001Z> 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 1373563271 16165 80.91.229.3 (11 Jul 2013 17:21:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 11 Jul 2013 17:21:11 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Thu Jul 11 19:21:13 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 1UxKYJ-00032i-ED for guile-user@m.gmane.org; Thu, 11 Jul 2013 19:21:11 +0200 Original-Received: from localhost ([::1]:45196 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UxKYI-0006gW-UK for guile-user@m.gmane.org; Thu, 11 Jul 2013 13:21:10 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46541) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UxFf1-0000JC-0o for guile-user@gnu.org; Thu, 11 Jul 2013 08:07:51 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UxFez-0002TC-NX for guile-user@gnu.org; Thu, 11 Jul 2013 08:07:46 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:45203) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UxFez-0002Sv-Hz for guile-user@gnu.org; Thu, 11 Jul 2013 08:07:45 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UxFeu-0003EN-Cy for guile-user@gnu.org; Thu, 11 Jul 2013 14:07:40 +0200 Original-Received: from 193.50.110.154 ([193.50.110.154]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 11 Jul 2013 14:07:40 +0200 Original-Received: from ludo by 193.50.110.154 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 11 Jul 2013 14:07:40 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 48 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 193.50.110.154 X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 23 Messidor an 221 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu User-Agent: Gnus/5.130007 (Ma Gnus v0.7) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:o/iZV9dfo1SYl1BoikDGlwyXDfI= 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: Thu, 11 Jul 2013 13:20:29 -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:10516 Archived-At: 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? > (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. No: single handlers are run from an async, but the ‘system-error’ for EINTR it thrown immediately. > I also tried a couple versions of `sigaction' without any luck: > > (sigaction SIGINT (lambda (signum) #t) SA_RESTART) > > and > > (sigaction SIGINT #f SA_RESTART) You mean you still get EINTR with that? In my experience SA_RESTART works as advertised, with the caveat that execution of system asyncs (such as signal handlers) are delayed until the syscall completes (see .) Thanks, Ludo’.