From unknown Sun Aug 10 00:43:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#30368: =?UTF-8?Q?=E2=80=98select=E2=80=99?= returns non-empty sets upon EINTR or EAGAIN Resent-From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Tue, 06 Feb 2018 10:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 30368 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: 30368@debbugs.gnu.org X-Debbugs-Original-To: bug-guile@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.151791358723951 (code B ref -1); Tue, 06 Feb 2018 10:40:02 +0000 Received: (at submit) by debbugs.gnu.org; 6 Feb 2018 10:39:47 +0000 Received: from localhost ([127.0.0.1]:59565 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ej0fC-0006EE-W1 for submit@debbugs.gnu.org; Tue, 06 Feb 2018 05:39:47 -0500 Received: from eggs.gnu.org ([208.118.235.92]:58151) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ej0fB-0006E0-HN for submit@debbugs.gnu.org; Tue, 06 Feb 2018 05:39:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ej0f5-00012f-6c for submit@debbugs.gnu.org; Tue, 06 Feb 2018 05:39:40 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_40,T_RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:56762) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ej0f5-00012Y-2g for submit@debbugs.gnu.org; Tue, 06 Feb 2018 05:39:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49111) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ej0f3-0001kb-Tm for bug-guile@gnu.org; Tue, 06 Feb 2018 05:39:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ej0ey-0000yu-WD for bug-guile@gnu.org; Tue, 06 Feb 2018 05:39:37 -0500 Received: from hera.aquilenet.fr ([2a0c:e300::1]:33734) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ej0ey-0000yI-Na for bug-guile@gnu.org; Tue, 06 Feb 2018 05:39:32 -0500 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 369589EF4 for ; Tue, 6 Feb 2018 11:39:31 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NUI8GNhcuEBr for ; Tue, 6 Feb 2018 11:39:30 +0100 (CET) Received: from ribbon (unknown [193.50.110.200]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 7A5CC6FF0 for ; Tue, 6 Feb 2018 11:39:30 +0100 (CET) From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 18 =?UTF-8?Q?Pluvi=C3=B4se?= an 226 de la =?UTF-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Tue, 06 Feb 2018 11:39:30 +0100 Message-ID: <87y3k67671.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello, As of Guile 2.2.3, the Scheme-level =E2=80=98select=E2=80=99 can return non= -empty sets when the C-level =E2=80=98select=E2=80=99 returns EINTR or EAGAIN. The pro= gram below illustrates this: --8<---------------cut here---------------start------------->8--- (use-modules (ice-9 match)) (sigaction SIGINT (lambda args (pk 'signal! args))) (let ((target (getpid))) (match (primitive-fork) ((? zero?) (sleep 4) (kill target SIGINT) (primitive-exit 0)) (_ #t))) (match (select (list (current-input-port)) '() '()) (((port) () ()) (pk 'reading-from port) (read-char port)) (lst (pk 'done lst))) --8<---------------cut here---------------end--------------->8--- On 2.2.3, it prints: --8<---------------cut here---------------start------------->8--- $ guile select.scm ;;; (signal! (2)) ;;; (reading-from #) --8<---------------cut here---------------end--------------->8--- >From there on it=E2=80=99s stuck in a read(0, =E2=80=A6) call. The attached patch fixes it by clearing the returned FD sets on EINTR/EAGAIN. (Besides it seems that select(2) never returns EAGAIN.) I=E2=80=99m not sure how to write a test for this; the one above is timing-sensitive, which wouldn=E2=80=99t be great. Thoughts? Ludo=E2=80=99. --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/libguile/filesys.c b/libguile/filesys.c index e39dc4a0d..05dd2bd16 100644 --- a/libguile/filesys.c +++ b/libguile/filesys.c @@ -1,5 +1,5 @@ /* Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2006, - * 2009, 2010, 2011, 2012, 2013, 2014, 2016, 2017 Free Software Foundation, Inc. + * 2009, 2010, 2011, 2012, 2013, 2014, 2016, 2017, 2018 Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -900,10 +900,20 @@ SCM_DEFINE (scm_select, "select", 3, 2, 0, int rv = scm_std_select (max_fd + 1, &read_set, &write_set, &except_set, time_ptr); - /* Let EINTR / EAGAIN cause a return to the user and let them loop - to run any asyncs that might be pending. */ - if (rv < 0 && errno != EINTR && errno != EAGAIN) - SCM_SYSERROR; + if (rv < 0) + { + /* Let EINTR / EAGAIN cause a return to the user and let them + loop to run any asyncs that might be pending. */ + if (errno != EINTR && errno != EAGAIN) + SCM_SYSERROR; + else + { + /* Return empty sets. */ + FD_ZERO (&read_set); + FD_ZERO (&write_set); + FD_ZERO (&except_set); + } + } } return scm_list_3 (retrieve_select_type (&read_set, read_ports_ready, reads), --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Feb 07 08:30:45 2018 Received: (at control) by debbugs.gnu.org; 7 Feb 2018 13:30:46 +0000 Received: from localhost ([127.0.0.1]:60952 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ejPoD-0007oG-Ml for submit@debbugs.gnu.org; Wed, 07 Feb 2018 08:30:45 -0500 Received: from hera.aquilenet.fr ([185.233.100.1]:35572) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ejPoB-0007o6-WB for control@debbugs.gnu.org; Wed, 07 Feb 2018 08:30:44 -0500 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id F35071072C for ; Wed, 7 Feb 2018 14:30:42 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aKpbplVUE0SK for ; Wed, 7 Feb 2018 14:30:42 +0100 (CET) Received: from ribbon (unknown [IPv6:2a01:e0a:1d:7270:af76:b9b:ca24:c465]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 207D010434 for ; Wed, 7 Feb 2018 14:30:42 +0100 (CET) Date: Wed, 07 Feb 2018 14:30:41 +0100 Message-Id: <87372d0vwe.fsf@gnu.org> To: control@debbugs.gnu.org From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: control message for bug #30368 MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) severity 30368 important From unknown Sun Aug 10 00:43:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#30368: =?UTF-8?Q?=E2=80=98select=E2=80=99?= returns non-empty sets upon EINTR or EAGAIN Resent-From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Wed, 07 Feb 2018 13:35:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 30368 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: 30368@debbugs.gnu.org Received: via spool by 30368-submit@debbugs.gnu.org id=B30368.151801044230366 (code B ref 30368); Wed, 07 Feb 2018 13:35:01 +0000 Received: (at 30368) by debbugs.gnu.org; 7 Feb 2018 13:34:02 +0000 Received: from localhost ([127.0.0.1]:60956 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ejPrO-0007ti-5K for submit@debbugs.gnu.org; Wed, 07 Feb 2018 08:34:02 -0500 Received: from hera.aquilenet.fr ([185.233.100.1]:35590) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ejPrM-0007tJ-E0 for 30368@debbugs.gnu.org; Wed, 07 Feb 2018 08:34:00 -0500 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id D47581075C for <30368@debbugs.gnu.org>; Wed, 7 Feb 2018 14:33:59 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TvIw4roFN__Z for <30368@debbugs.gnu.org>; Wed, 7 Feb 2018 14:33:59 +0100 (CET) Received: from ribbon (unknown [IPv6:2a01:e0a:1d:7270:af76:b9b:ca24:c465]) by hera.aquilenet.fr (Postfix) with ESMTPSA id E73C910434 for <30368@debbugs.gnu.org>; Wed, 7 Feb 2018 14:33:58 +0100 (CET) From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) References: <87y3k67671.fsf@gnu.org> Date: Wed, 07 Feb 2018 14:33:58 +0100 In-Reply-To: <87y3k67671.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Tue, 06 Feb 2018 11:39:30 +0100") Message-ID: <87y3k4zzy1.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 1.0 (+) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) ludo@gnu.org (Ludovic Court=C3=A8s) skribis: > On 2.2.3, it prints: > > $ guile select.scm > > > ;;; (signal! (2)) > ;;; (reading-from #) > >>>From there on it=E2=80=99s stuck in a read(0, =E2=80=A6) call. > > The attached patch fixes it by clearing the returned FD sets on > EINTR/EAGAIN. There=E2=80=99s a case where we can get a =E2=80=9Cfake=E2=80=9D EINTR that= doesn=E2=80=99t come from the underlying select(2) call: when the =E2=80=98scm_i_prepare_to_wait_on_f= d=E2=80=99 call in =E2=80=98scm_std_select=E2=80=99 returns 1, which happens when new = asyncs have been queued. Ludo=E2=80=99. From unknown Sun Aug 10 00:43:10 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Subject: bug#30368: closed (Re: bug#30368: =?UTF-8?Q?=E2=80=98select=E2=80=99?= returns non-empty sets upon EINTR or EAGAIN) Message-ID: References: <878tbtngwv.fsf@gnu.org> <87y3k67671.fsf@gnu.org> X-Gnu-PR-Message: they-closed 30368 X-Gnu-PR-Package: guile Reply-To: 30368@debbugs.gnu.org Date: Fri, 16 Feb 2018 14:34:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1518791642-17385-1" This is a multi-part message in MIME format... ------------=_1518791642-17385-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #30368: =E2=80=98select=E2=80=99 returns non-empty sets upon EINTR or EAGAIN which was filed against the guile package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 30368@debbugs.gnu.org. --=20 30368: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D30368 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1518791642-17385-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 30368-done) by debbugs.gnu.org; 16 Feb 2018 14:33:07 +0000 Received: from localhost ([127.0.0.1]:45834 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1emh4V-0004Uu-3S for submit@debbugs.gnu.org; Fri, 16 Feb 2018 09:33:07 -0500 Received: from hera.aquilenet.fr ([185.233.100.1]:35130) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1emh4T-0004Un-GK for 30368-done@debbugs.gnu.org; Fri, 16 Feb 2018 09:33:05 -0500 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 0A10B115E1 for <30368-done@debbugs.gnu.org>; Fri, 16 Feb 2018 15:33:05 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lxDPebN1QLYB for <30368-done@debbugs.gnu.org>; Fri, 16 Feb 2018 15:33:04 +0100 (CET) Received: from ribbon (unknown [193.50.110.160]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 66A12115AC for <30368-done@debbugs.gnu.org>; Fri, 16 Feb 2018 15:33:04 +0100 (CET) From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) To: 30368-done@debbugs.gnu.org Subject: Re: bug#30368: =?utf-8?B?4oCYc2VsZWN04oCZ?= returns non-empty sets upon EINTR or EAGAIN References: <87y3k67671.fsf@gnu.org> Date: Fri, 16 Feb 2018 15:33:04 +0100 In-Reply-To: <87y3k67671.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Tue, 06 Feb 2018 11:39:30 +0100") Message-ID: <878tbtngwv.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 30368-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) ludo@gnu.org (Ludovic Court=C3=A8s) skribis: > The attached patch fixes it by clearing the returned FD sets on > EINTR/EAGAIN. Pushed as f390afa0cc84eb84ed2cb3e03f542b991d4bb080. Ludo=E2=80=99. ------------=_1518791642-17385-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 6 Feb 2018 10:39:47 +0000 Received: from localhost ([127.0.0.1]:59565 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ej0fC-0006EE-W1 for submit@debbugs.gnu.org; Tue, 06 Feb 2018 05:39:47 -0500 Received: from eggs.gnu.org ([208.118.235.92]:58151) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ej0fB-0006E0-HN for submit@debbugs.gnu.org; Tue, 06 Feb 2018 05:39:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ej0f5-00012f-6c for submit@debbugs.gnu.org; Tue, 06 Feb 2018 05:39:40 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_40,T_RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:56762) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ej0f5-00012Y-2g for submit@debbugs.gnu.org; Tue, 06 Feb 2018 05:39:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49111) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ej0f3-0001kb-Tm for bug-guile@gnu.org; Tue, 06 Feb 2018 05:39:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ej0ey-0000yu-WD for bug-guile@gnu.org; Tue, 06 Feb 2018 05:39:37 -0500 Received: from hera.aquilenet.fr ([2a0c:e300::1]:33734) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ej0ey-0000yI-Na for bug-guile@gnu.org; Tue, 06 Feb 2018 05:39:32 -0500 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 369589EF4 for ; Tue, 6 Feb 2018 11:39:31 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NUI8GNhcuEBr for ; Tue, 6 Feb 2018 11:39:30 +0100 (CET) Received: from ribbon (unknown [193.50.110.200]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 7A5CC6FF0 for ; Tue, 6 Feb 2018 11:39:30 +0100 (CET) From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) To: bug-guile@gnu.org Subject: =?utf-8?B?4oCYc2VsZWN04oCZ?= returns non-empty sets upon EINTR or EAGAIN X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 18 =?utf-8?Q?Pluvi=C3=B4se?= an 226 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Tue, 06 Feb 2018 11:39:30 +0100 Message-ID: <87y3k67671.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello, As of Guile 2.2.3, the Scheme-level =E2=80=98select=E2=80=99 can return non= -empty sets when the C-level =E2=80=98select=E2=80=99 returns EINTR or EAGAIN. The pro= gram below illustrates this: --8<---------------cut here---------------start------------->8--- (use-modules (ice-9 match)) (sigaction SIGINT (lambda args (pk 'signal! args))) (let ((target (getpid))) (match (primitive-fork) ((? zero?) (sleep 4) (kill target SIGINT) (primitive-exit 0)) (_ #t))) (match (select (list (current-input-port)) '() '()) (((port) () ()) (pk 'reading-from port) (read-char port)) (lst (pk 'done lst))) --8<---------------cut here---------------end--------------->8--- On 2.2.3, it prints: --8<---------------cut here---------------start------------->8--- $ guile select.scm ;;; (signal! (2)) ;;; (reading-from #) --8<---------------cut here---------------end--------------->8--- >From there on it=E2=80=99s stuck in a read(0, =E2=80=A6) call. The attached patch fixes it by clearing the returned FD sets on EINTR/EAGAIN. (Besides it seems that select(2) never returns EAGAIN.) I=E2=80=99m not sure how to write a test for this; the one above is timing-sensitive, which wouldn=E2=80=99t be great. Thoughts? Ludo=E2=80=99. --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/libguile/filesys.c b/libguile/filesys.c index e39dc4a0d..05dd2bd16 100644 --- a/libguile/filesys.c +++ b/libguile/filesys.c @@ -1,5 +1,5 @@ /* Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2006, - * 2009, 2010, 2011, 2012, 2013, 2014, 2016, 2017 Free Software Foundation, Inc. + * 2009, 2010, 2011, 2012, 2013, 2014, 2016, 2017, 2018 Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -900,10 +900,20 @@ SCM_DEFINE (scm_select, "select", 3, 2, 0, int rv = scm_std_select (max_fd + 1, &read_set, &write_set, &except_set, time_ptr); - /* Let EINTR / EAGAIN cause a return to the user and let them loop - to run any asyncs that might be pending. */ - if (rv < 0 && errno != EINTR && errno != EAGAIN) - SCM_SYSERROR; + if (rv < 0) + { + /* Let EINTR / EAGAIN cause a return to the user and let them + loop to run any asyncs that might be pending. */ + if (errno != EINTR && errno != EAGAIN) + SCM_SYSERROR; + else + { + /* Return empty sets. */ + FD_ZERO (&read_set); + FD_ZERO (&write_set); + FD_ZERO (&except_set); + } + } } return scm_list_3 (retrieve_select_type (&read_set, read_ports_ready, reads), --=-=-=-- ------------=_1518791642-17385-1--