From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.bugs Subject: bug#14640: SA_RESTART prevents execution of signal handlers Date: Tue, 21 Jun 2016 09:59:33 +0200 Message-ID: <8737o73rbu.fsf@pobox.com> References: <87sj0gx2oq.fsf@inria.fr> <87twgn59ou.fsf@pobox.com> <87wpljdlta.fsf@inria.fr> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1466497178 23646 80.91.229.3 (21 Jun 2016 08:19:38 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 21 Jun 2016 08:19:38 +0000 (UTC) Cc: 14640-done@debbugs.gnu.org, ludo@gnu.org To: ludovic.courtes@inria.fr (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Tue Jun 21 10:19:26 2016 Return-path: Envelope-to: guile-bugs@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 1bFGu4-0007ng-EP for guile-bugs@m.gmane.org; Tue, 21 Jun 2016 10:19:24 +0200 Original-Received: from localhost ([::1]:49633 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFGu3-0004hV-J7 for guile-bugs@m.gmane.org; Tue, 21 Jun 2016 04:19:23 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35126) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFGbQ-0008CC-53 for bug-guile@gnu.org; Tue, 21 Jun 2016 04:00:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bFGbM-0005KH-3G for bug-guile@gnu.org; Tue, 21 Jun 2016 04:00:08 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:36173) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFGbL-0005K2-WE for bug-guile@gnu.org; Tue, 21 Jun 2016 04:00:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bFGbL-0001tU-RY for bug-guile@gnu.org; Tue, 21 Jun 2016 04:00:03 -0400 X-Loop: help-debbugs@gnu.org 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: Original-Received: via spool by 14640-done@debbugs.gnu.org id=D14640.14664959837214 (code D ref 14640); Tue, 21 Jun 2016 08:00:03 +0000 Original-Received: (at 14640-done) by debbugs.gnu.org; 21 Jun 2016 07:59:43 +0000 Original-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 Original-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 Original-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= Original-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) Original-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) 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") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-Pobox-Relay-ID: 1B4B134A-3786-11E6-91FD-C1836462E9F6-02397024!pb-sasl1.pobox.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: "bug-guile" Xref: news.gmane.org gmane.lisp.guile.bugs:8064 Archived-At: 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