From unknown Tue Jun 17 01:48:45 2025 X-Loop: help-debbugs@gnu.org Subject: bug#14640: SA_RESTART prevents execution of signal handlers Resent-From: ludovic.courtes@inria.fr (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Mon, 17 Jun 2013 14:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 14640 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: 14640@debbugs.gnu.org X-Debbugs-Original-To: bug-guile@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.137147797531824 (code B ref -1); Mon, 17 Jun 2013 14:07:02 +0000 Received: (at submit) by debbugs.gnu.org; 17 Jun 2013 14:06:15 +0000 Received: from localhost ([127.0.0.1]:50693 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Uoa4V-0008HC-3a for submit@debbugs.gnu.org; Mon, 17 Jun 2013 10:06:15 -0400 Received: from eggs.gnu.org ([208.118.235.92]:34540) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Uoa4S-0008Gi-Uo for submit@debbugs.gnu.org; Mon, 17 Jun 2013 10:06:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uoa4G-0001ae-FT for submit@debbugs.gnu.org; Mon, 17 Jun 2013 10:06:07 -0400 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_20 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:41417) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uoa4G-0001aK-CK for submit@debbugs.gnu.org; Mon, 17 Jun 2013 10:06:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36239) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uoa4D-0006da-91 for bug-guile@gnu.org; Mon, 17 Jun 2013 10:06:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UoZtR-0006FF-7K for bug-guile@gnu.org; Mon, 17 Jun 2013 09:56:02 -0400 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:8254) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UoZtQ-0006Eh-V3 for bug-guile@gnu.org; Mon, 17 Jun 2013 09:54:49 -0400 X-IronPort-AV: E=Sophos;i="4.87,881,1363129200"; d="scan'208";a="18049316" Received: from reverse-83.fdn.fr (HELO pluto) ([80.67.176.83]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 17 Jun 2013 15:54:46 +0200 From: ludovic.courtes@inria.fr (Ludovic =?UTF-8?Q?Court=C3=A8s?=) X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 29 Prairial 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 Date: Mon, 17 Jun 2013 15:54:45 +0200 Message-ID: <87sj0gx2oq.fsf@inria.fr> User-Agent: Gnus/5.130007 (Ma Gnus v0.7) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). 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.15 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 (-----) When using SA_RESTART, signal handlers are never executed, as in this example (checked on 2.0.9+): --8<---------------cut here---------------start------------->8--- (sigaction SIGALRM (lambda (signum) (pk 'sig signum)) SA_RESTART) (alarm 3) (pk 'char (read-char)) --8<---------------cut here---------------end--------------->8--- Presumably this is because the read(2) syscall is automatically restarted, leaving no chance for the handler async to run. Ludo=E2=80=99. From unknown Tue Jun 17 01:48:45 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: ludovic.courtes@inria.fr (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Subject: bug#14640: closed (Re: bug#14640: SA_RESTART prevents execution of signal handlers) Message-ID: References: <87twgn59ou.fsf@pobox.com> <87sj0gx2oq.fsf@inria.fr> X-Gnu-PR-Message: they-closed 14640 X-Gnu-PR-Package: guile Reply-To: 14640@debbugs.gnu.org Date: Tue, 21 Jun 2016 06:38:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1466491082-31947-1" This is a multi-part message in MIME format... ------------=_1466491082-31947-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #14640: SA_RESTART prevents execution of signal handlers 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 14640@debbugs.gnu.org. --=20 14640: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D14640 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1466491082-31947-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 14640-done) by debbugs.gnu.org; 21 Jun 2016 06:37:52 +0000 Received: from localhost ([127.0.0.1]:48420 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bFFJo-0008Is-Hy for submit@debbugs.gnu.org; Tue, 21 Jun 2016 02:37:52 -0400 Received: from pb-sasl2.pobox.com ([64.147.108.67]:63918 helo=sasl.smtp.pobox.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bFFJm-0008Ik-O2 for 14640-done@debbugs.gnu.org; Tue, 21 Jun 2016 02:37:51 -0400 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-sasl2.pobox.com (Postfix) with ESMTP id 02C912041B; Tue, 21 Jun 2016 02:37:48 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; s=sasl; bh=rlZZCG9BQqFv i7yPU6JSHI0T8vw=; b=VI2SzrWFKQ5c+NUgMjYpES9OonQl3A/zBypw1D7u6FRW pKSaPDdlx/CIamIWU+JlgNGxsjKUaU1aNX9h58gq1mU9la2Q7AHnwR1tQRmaIxpU Mzrv0wDUFbpTr3Or73gnU20WvSG8h+fNWV2esVAhTJdPekVDFwq/078K26S5YrQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; q=dns; s=sasl; b=GSWg+r bZfLmZWf+E7LTWOrBtz378Mljxdx86z3qaCKBejWDYVbj9K//Q3Ufq0jp1zrqoGf qase26tmI3YhttJaFKG/UlnULZ8wwajhdEVkMcQOVdK7LUTItvYP93+kYnOeGKct 5sX+qf+ImGlZe+jucl+zYjxsuSETDoPPuf5S4= Received: from pb-sasl2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-sasl2.pobox.com (Postfix) with ESMTP id EFE8B20419; Tue, 21 Jun 2016 02:37:47 -0400 (EDT) Received: from clucks (unknown [88.160.190.192]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by pb-sasl2.pobox.com (Postfix) with ESMTPSA id 1C31620418; Tue, 21 Jun 2016 02:37:45 -0400 (EDT) From: Andy Wingo To: ludovic.courtes@inria.fr (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: bug#14640: SA_RESTART prevents execution of signal handlers References: <87sj0gx2oq.fsf@inria.fr> Date: Tue, 21 Jun 2016 08:37:37 +0200 In-Reply-To: <87sj0gx2oq.fsf@inria.fr> ("Ludovic =?utf-8?Q?Court=C3=A8s=22?= =?utf-8?Q?'s?= message of "Mon, 17 Jun 2013 15:54:45 +0200") Message-ID: <87twgn59ou.fsf@pobox.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Pobox-Relay-ID: AAE21460-377A-11E6-A9B4-28A6F1301B6D-02397024!pb-sasl2.pobox.com X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: 14640-done Cc: 14640-done@debbugs.gnu.org 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.4 (-) On Mon 17 Jun 2013 15:54, ludovic.courtes@inria.fr (Ludovic Court=C3=A8s) w= rites: > When using SA_RESTART, signal handlers are never executed, as in this > example (checked on 2.0.9+): > > (sigaction SIGALRM > (lambda (signum) > (pk 'sig signum)) > SA_RESTART) > (alarm 3) > (pk 'char (read-char)) > > Presumably this is because the read(2) syscall is automatically > restarted, leaving no chance for the handler async to run. Thinking about this a bit -- since we always handle signals asynchronously and have no intention of handling them synchronously, then we just have to document this behavior. Done in e877e1b: Guile handles signals asynchronously. When it receives a signal, the synchronous signal handler just records the fact that a signal was received and sets a flag to tell the relevant Guile thread that it has a pending signal. When the Guile thread checks the pending-interrupt flag, it will arrange to run the asynchronous part of the signal handler, which is the handler attached by @code{sigaction}. This strategy has some perhaps-unexpected interactions with the @code{SA_RESTART} flag, though: because the synchronous handler doesn't do very much, and notably it doesn't run the Guile handler, it's impossible to interrupt a thread stuck in a long-running system call via a signal handler that is installed with @code{SA_RESTART}: the synchronous handler just records the pending interrupt, but then the system call resumes and Guile doesn't have a chance to actually check the flag and run the asynchronous handler. That's just how it is. Andy ------------=_1466491082-31947-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 17 Jun 2013 14:06:15 +0000 Received: from localhost ([127.0.0.1]:50693 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Uoa4V-0008HC-3a for submit@debbugs.gnu.org; Mon, 17 Jun 2013 10:06:15 -0400 Received: from eggs.gnu.org ([208.118.235.92]:34540) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Uoa4S-0008Gi-Uo for submit@debbugs.gnu.org; Mon, 17 Jun 2013 10:06:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uoa4G-0001ae-FT for submit@debbugs.gnu.org; Mon, 17 Jun 2013 10:06:07 -0400 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_20 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:41417) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uoa4G-0001aK-CK for submit@debbugs.gnu.org; Mon, 17 Jun 2013 10:06:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36239) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uoa4D-0006da-91 for bug-guile@gnu.org; Mon, 17 Jun 2013 10:06:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UoZtR-0006FF-7K for bug-guile@gnu.org; Mon, 17 Jun 2013 09:56:02 -0400 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:8254) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UoZtQ-0006Eh-V3 for bug-guile@gnu.org; Mon, 17 Jun 2013 09:54:49 -0400 X-IronPort-AV: E=Sophos;i="4.87,881,1363129200"; d="scan'208";a="18049316" Received: from reverse-83.fdn.fr (HELO pluto) ([80.67.176.83]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 17 Jun 2013 15:54:46 +0200 From: ludovic.courtes@inria.fr (Ludovic =?utf-8?Q?Court=C3=A8s?=) To: bug-guile@gnu.org Subject: SA_RESTART prevents execution of signal handlers X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 29 Prairial 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 Date: Mon, 17 Jun 2013 15:54:45 +0200 Message-ID: <87sj0gx2oq.fsf@inria.fr> User-Agent: Gnus/5.130007 (Ma Gnus v0.7) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). 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.15 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 (-----) When using SA_RESTART, signal handlers are never executed, as in this example (checked on 2.0.9+): --8<---------------cut here---------------start------------->8--- (sigaction SIGALRM (lambda (signum) (pk 'sig signum)) SA_RESTART) (alarm 3) (pk 'char (read-char)) --8<---------------cut here---------------end--------------->8--- Presumably this is because the read(2) syscall is automatically restarted, leaving no chance for the handler async to run. Ludo=E2=80=99. ------------=_1466491082-31947-1-- From unknown Tue Jun 17 01:48:45 2025 X-Loop: help-debbugs@gnu.org Subject: bug#14640: SA_RESTART prevents execution of signal handlers Resent-From: ludovic.courtes@inria.fr (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Tue, 21 Jun 2016 07:49:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 14640 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: Andy Wingo Cc: 14640-done@debbugs.gnu.org Reply-To: ludo@gnu.org Received: via spool by 14640-done@debbugs.gnu.org id=D14640.14664953236175 (code D ref 14640); Tue, 21 Jun 2016 07:49:02 +0000 Received: (at 14640-done) by debbugs.gnu.org; 21 Jun 2016 07:48:43 +0000 Received: from localhost ([127.0.0.1]:48488 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bFGQN-0001bW-5s for submit@debbugs.gnu.org; Tue, 21 Jun 2016 03:48:43 -0400 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:43617) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bFGQK-0001bF-HS for 14640-done@debbugs.gnu.org; Tue, 21 Jun 2016 03:48:41 -0400 X-IronPort-AV: E=Sophos;i="5.26,502,1459807200"; d="scan'208";a="181948410" Received: from pluto.bordeaux.inria.fr (HELO pluto) ([193.50.110.57]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 21 Jun 2016 09:48:33 +0200 From: ludovic.courtes@inria.fr (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Organization: Inria Bordeaux Sud-Ouest References: <87sj0gx2oq.fsf@inria.fr> <87twgn59ou.fsf@pobox.com> X-URL: http://people.bordeaux.inria.fr/lcourtes/ X-Revolutionary-Date: 4 Messidor an 224 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-unknown-linux-gnu Date: Tue, 21 Jun 2016 09:48:33 +0200 In-Reply-To: <87twgn59ou.fsf@pobox.com> (Andy Wingo's message of "Tue, 21 Jun 2016 08:37:37 +0200") Message-ID: <87wpljdlta.fsf@inria.fr> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -6.4 (------) 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: -6.4 (------) Andy Wingo skribis: > On Mon 17 Jun 2013 15:54, ludovic.courtes@inria.fr (Ludovic Court=C3=A8s)= writes: > >> When using SA_RESTART, signal handlers are never executed, as in this >> example (checked on 2.0.9+): >> >> (sigaction SIGALRM >> (lambda (signum) >> (pk 'sig signum)) >> SA_RESTART) >> (alarm 3) >> (pk 'char (read-char)) >> >> Presumably this is because the read(2) syscall is automatically >> restarted, leaving no chance for the handler async to run. > > Thinking about this a bit -- since we always handle signals > asynchronously and have no intention of handling them synchronously, > then we just have to document this behavior. Done in e877e1b: I think it=E2=80=99s problematic though. With the current design, signal delivery is unreliable (with or without SA_RESTART; what we observe with SA_RESTART occurs similarly if you make a syscall right after queuing, but not running, an async.) The more I think about it, the more I think a different approach is needed. On GNU/Linux, signalfd(2) may be part of the solution. Ludo=E2=80=99. From unknown Tue Jun 17 01:48:45 2025 X-Loop: help-debbugs@gnu.org Subject: bug#14640: SA_RESTART prevents execution of signal handlers Resent-From: Andy Wingo Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Tue, 21 Jun 2016 08:00:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 14640 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: ludovic.courtes@inria.fr (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Cc: 14640-done@debbugs.gnu.org, ludo@gnu.org Received: via spool by 14640-done@debbugs.gnu.org id=D14640.14664959837214 (code D ref 14640); Tue, 21 Jun 2016 08:00:03 +0000 Received: (at 14640-done) by debbugs.gnu.org; 21 Jun 2016 07:59:43 +0000 Received: from localhost ([127.0.0.1]:48509 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bFGb1-0001sI-7C for submit@debbugs.gnu.org; Tue, 21 Jun 2016 03:59:43 -0400 Received: from pb-sasl1.pobox.com ([64.147.108.66]:63842 helo=sasl.smtp.pobox.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bFGb0-0001sB-By for 14640-done@debbugs.gnu.org; Tue, 21 Jun 2016 03:59:42 -0400 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-sasl1.pobox.com (Postfix) with ESMTP id 03E352108C; Tue, 21 Jun 2016 03:59:41 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; s=sasl; bh=5n51Bk7ki2AT +Rie2xQvDzhbyhM=; b=GMQ+hYuQzDmVB0kFszlVS+IxIVzo2pmLJrnUWMgllnLT CmxgHHg/owQSC3dOxFDa5bWAOhW979sek18D3H9Tnk/Anf6jkmPTxfPb6tFnGNX0 XBRZ1BP0I4r6+AfLOWECw1T7gONKlNK0yc6H0Iw9d9anF8Y/Rpd35PIY/wAr83U= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; q=dns; s=sasl; b=Q2eyFs 2RhQkcB6zPDkucMaYmLivxukT1Ql3G3bxCUHAauIJGocBFjBCfOO0zU89wCuDAI5 pWdENpRODt8wXWneT6qJsyvN+x2KGEMuFPsqqQfsJ1VsTeA0fbyxdXKXpygJdH9U aTu91RGKP7gTwBJtSp5JACMRo3bEuqOEjkqCY= Received: from pb-sasl1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-sasl1.pobox.com (Postfix) with ESMTP id F0A392108B; Tue, 21 Jun 2016 03:59:40 -0400 (EDT) Received: from clucks (unknown [88.160.190.192]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by pb-sasl1.pobox.com (Postfix) with ESMTPSA id 4E88D2108A; Tue, 21 Jun 2016 03:59:40 -0400 (EDT) From: Andy Wingo References: <87sj0gx2oq.fsf@inria.fr> <87twgn59ou.fsf@pobox.com> <87wpljdlta.fsf@inria.fr> Date: Tue, 21 Jun 2016 09:59:33 +0200 In-Reply-To: <87wpljdlta.fsf@inria.fr> ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Tue, 21 Jun 2016 09:48:33 +0200") Message-ID: <8737o73rbu.fsf@pobox.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Pobox-Relay-ID: 1B4B134A-3786-11E6-91FD-C1836462E9F6-02397024!pb-sasl1.pobox.com X-Spam-Score: -1.4 (-) 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.4 (-) On Tue 21 Jun 2016 09:48, ludovic.courtes@inria.fr (Ludovic Court=C3=A8s) w= rites: > Andy Wingo skribis: > >> On Mon 17 Jun 2013 15:54, ludovic.courtes@inria.fr (Ludovic Court=C3=A8s= ) writes: >> >>> When using SA_RESTART, signal handlers are never executed, as in this >>> example (checked on 2.0.9+): >>> >>> (sigaction SIGALRM >>> (lambda (signum) >>> (pk 'sig signum)) >>> SA_RESTART) >>> (alarm 3) >>> (pk 'char (read-char)) >>> >>> Presumably this is because the read(2) syscall is automatically >>> restarted, leaving no chance for the handler async to run. >> >> Thinking about this a bit -- since we always handle signals >> asynchronously and have no intention of handling them synchronously, >> then we just have to document this behavior. Done in e877e1b: > > I think it=E2=80=99s problematic though. With the current design, signal > delivery is unreliable (with or without SA_RESTART; what we observe with > SA_RESTART occurs similarly if you make a syscall right after queuing, > but not running, an async.) Can you expect any kind of reasonable behavior with SA_RESTART? I think not. > The more I think about it, the more I think a different approach is > needed. On GNU/Linux, signalfd(2) may be part of the solution. We already do the equivalent of signalfd(), with our self-pipe trick. And an fd doesn't help you if the syscall has no associated fd. Signals are just a problem. I agree we can do better though :) If you are just concerned about read and write, I think the right thing is non-blocking fd's, and making the C read/write waiters also add the signal FD to their poll set. WDYT? Andy From unknown Tue Jun 17 01:48:45 2025 X-Loop: help-debbugs@gnu.org Subject: bug#14640: SA_RESTART prevents execution of signal handlers 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, 21 Jun 2016 09:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 14640 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: Andy Wingo Cc: 14640-done@debbugs.gnu.org Received: via spool by 14640-done@debbugs.gnu.org id=D14640.146650241217903 (code D ref 14640); Tue, 21 Jun 2016 09:47:02 +0000 Received: (at 14640-done) by debbugs.gnu.org; 21 Jun 2016 09:46:52 +0000 Received: from localhost ([127.0.0.1]:48571 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bFIGi-0004eg-90 for submit@debbugs.gnu.org; Tue, 21 Jun 2016 05:46:52 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51464) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bFIGg-0004eR-Ps for 14640-done@debbugs.gnu.org; Tue, 21 Jun 2016 05:46:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bFIGX-0005iz-Ci for 14640-done@debbugs.gnu.org; Tue, 21 Jun 2016 05:46:45 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:39598) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFIGX-0005ir-9V; Tue, 21 Jun 2016 05:46:41 -0400 Received: from pluto.bordeaux.inria.fr ([193.50.110.57]:41350 helo=pluto) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1bFIGV-0005AC-LD; Tue, 21 Jun 2016 05:46:39 -0400 From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) References: <87sj0gx2oq.fsf@inria.fr> <87twgn59ou.fsf@pobox.com> <87wpljdlta.fsf@inria.fr> <8737o73rbu.fsf@pobox.com> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 4 Messidor an 224 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-unknown-linux-gnu Date: Tue, 21 Jun 2016 11:46:37 +0200 In-Reply-To: <8737o73rbu.fsf@pobox.com> (Andy Wingo's message of "Tue, 21 Jun 2016 09:59:33 +0200") Message-ID: <87eg7qc1s2.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -6.4 (------) 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: -6.4 (------) Andy Wingo skribis: > On Tue 21 Jun 2016 09:48, ludovic.courtes@inria.fr (Ludovic Court=C3=A8s)= writes: > >> Andy Wingo skribis: >> >>> On Mon 17 Jun 2013 15:54, ludovic.courtes@inria.fr (Ludovic Court=C3=A8= s) writes: >>> >>>> When using SA_RESTART, signal handlers are never executed, as in this >>>> example (checked on 2.0.9+): >>>> >>>> (sigaction SIGALRM >>>> (lambda (signum) >>>> (pk 'sig signum)) >>>> SA_RESTART) >>>> (alarm 3) >>>> (pk 'char (read-char)) >>>> >>>> Presumably this is because the read(2) syscall is automatically >>>> restarted, leaving no chance for the handler async to run. >>> >>> Thinking about this a bit -- since we always handle signals >>> asynchronously and have no intention of handling them synchronously, >>> then we just have to document this behavior. Done in e877e1b: >> >> I think it=E2=80=99s problematic though. With the current design, signal >> delivery is unreliable (with or without SA_RESTART; what we observe with >> SA_RESTART occurs similarly if you make a syscall right after queuing, >> but not running, an async.) > > Can you expect any kind of reasonable behavior with SA_RESTART? I think > not. In C it does its job: signal handlers run, and other parts of the code don=E2=80=99t notice the interruption. Here it=E2=80=99s useless. >> The more I think about it, the more I think a different approach is >> needed. On GNU/Linux, signalfd(2) may be part of the solution. > > We already do the equivalent of signalfd(), with our self-pipe trick. Hmm, I wonder if it=E2=80=99s really equivalent. Also, it is internal: the Scheme level cannot explicitly =E2=80=9Cconvert= =E2=80=9D signals to FDs; all it gets is those asyncs. > And an fd doesn't help you if the syscall has no associated fd. But those typically don=E2=80=99t block. > If you are just concerned about read and write, I think the right thing > is non-blocking fd's, and making the C read/write waiters also add the > signal FD to their poll set. WDYT? There=E2=80=99s also =E2=80=98select=E2=80=99. In the case of the Shepherd= , you=E2=80=99re in a =E2=80=98select=E2=80=99 loop, waiting for events from file descriptors *an= d* waiting for SIGCHLD. However, the SIGCHLD handler can end up running long after the fact. In this case, it would help to explicitly use use =E2=80=98signa= lfd=E2=80=99 at the Scheme level (whether it=E2=80=99s used internally in libguile doesn= =E2=80=99t matter.) Not sure I follow your suggestion. My na=C3=AFve view is that one would probably expect/want signals to behave =E2=80=9Clike in C=E2=80=9D, meaning= that handlers would run in a timely fashion once the signal has effectively been received by libguile. Thanks for your feedback! Ludo=E2=80=99.