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 08:37:37 +0200 Message-ID: <87twgn59ou.fsf@pobox.com> References: <87sj0gx2oq.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 1466491122 28645 80.91.229.3 (21 Jun 2016 06:38:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 21 Jun 2016 06:38:42 +0000 (UTC) Cc: 14640-done@debbugs.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 08:38:27 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 1bFFKM-0006b2-Ov for guile-bugs@m.gmane.org; Tue, 21 Jun 2016 08:38:26 +0200 Original-Received: from localhost ([::1]:49157 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFFKI-00012p-RP for guile-bugs@m.gmane.org; Tue, 21 Jun 2016 02:38:22 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43758) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFFK6-0000yP-PZ for bug-guile@gnu.org; Tue, 21 Jun 2016 02:38:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bFFJy-0005qL-UJ for bug-guile@gnu.org; Tue, 21 Jun 2016 02:38:09 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:36083) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFFJy-0005pM-CH for bug-guile@gnu.org; Tue, 21 Jun 2016 02:38:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bFFJy-0008JO-7e for bug-guile@gnu.org; Tue, 21 Jun 2016 02:38:02 -0400 Resent-From: Andy Wingo Original-Sender: "Debbugs-submit" Resent-To: bug-guile@gnu.org Resent-Date: Tue, 21 Jun 2016 06:38:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 14640 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Mail-Followup-To: 14640@debbugs.gnu.org, wingo@pobox.com, ludovic.courtes@inria.fr Original-Received: via spool by 14640-done@debbugs.gnu.org id=D14640.146649107231926 (code D ref 14640); Tue, 21 Jun 2016 06:38:01 +0000 Original-Received: (at 14640-done) by debbugs.gnu.org; 21 Jun 2016 06:37:52 +0000 Original-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 Original-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 Original-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= Original-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) 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-sasl2.pobox.com (Postfix) with ESMTPSA id 1C31620418; Tue, 21 Jun 2016 02:37:45 -0400 (EDT) In-Reply-To: <87sj0gx2oq.fsf@inria.fr> ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Mon, 17 Jun 2013 15:54:45 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-Pobox-Relay-ID: AAE21460-377A-11E6-A9B4-28A6F1301B6D-02397024!pb-sasl2.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:8052 Archived-At: 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