From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 61012 invoked by alias); 19 Aug 2017 08:01:46 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 60754 invoked by uid 89); 19 Aug 2017 08:01:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM autolearn=no version=3.3.2 spammy=conclusion, HX-Received:Sat, receipt, mutual X-HELO: mail-qk0-f180.google.com Received: from mail-qk0-f180.google.com (HELO mail-qk0-f180.google.com) (209.85.220.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 19 Aug 2017 08:01:18 +0000 Received: by mail-qk0-f180.google.com with SMTP id a77so63501995qkb.0 for ; Sat, 19 Aug 2017 01:01:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=S07ne2bG/DubGcR/bv7hJZpWJK9N0DzkqL6YfBAplCA=; b=thd47V2TLlotYUHVoY9CX4gBSWF/1Nbhx1JXIDW194enV8APdfhRhNVk+T4wo7vcNB c+9zyF/tYL0/nmYo98unIwk3ItHoRVQPEkdhICoVemDgR7HR+C07fE4uopOWY8k0xnHl soAwZ7KIq6eTlqUVEmwzbrVQYyWvDovITNL5EnU7W6cnTBgVDZv9VM0qJraYOLQ9I7Ty uCshXfbn/7rUCxTzWzO+MBC3HkANM6vvqXePlQJRQZBBm6xoCxXq01LsXo+YfqAhwpJe wjYAcOXIz6nXsMt9WVwV+9e9Kl2Qy7OKhS5DjvogAtWOyBY1r9+bSmfAUOXv8drSuIPF j8rA== X-Gm-Message-State: AHYfb5jqK9fvhozO4XhZ/FWt6dv2/uhSntpnCpNtWH+DiXKVttl2RNBj 6+k8e9P4YYYIAMnK X-Received: by 10.55.165.65 with SMTP id o62mr14470171qke.347.1503129675268; Sat, 19 Aug 2017 01:01:15 -0700 (PDT) Received: from rfd.leadboat.com (c-73-158-248-138.hsd1.ca.comcast.net. [73.158.248.138]) by smtp.gmail.com with ESMTPSA id e52sm1492595qtk.10.2017.08.19.01.01.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 19 Aug 2017 01:01:14 -0700 (PDT) Date: Sat, 19 Aug 2017 08:01:00 -0000 From: Noah Misch To: Houder Cc: cygwin@cygwin.com Subject: Re: Signal delivered while blocked Message-ID: <20170819080110.GA4022431@rfd.leadboat.com> References: <20170804074445.GB3154757@rfd.leadboat.com> <8f7f7f8ae098c1321f608645c750cae4@smtp-cloud7.xs4all.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8f7f7f8ae098c1321f608645c750cae4@smtp-cloud7.xs4all.net> User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes X-SW-Source: 2017-08/txt/msg00175.txt.bz2 On Mon, Aug 14, 2017 at 08:03:07AM +0200, Houder wrote: > On Fri, 4 Aug 2017 00:44:45, Noah Misch wrote: > > The attached demonstration program blocks signals (with sigprocmask()) to > > achieve mutual exclusion between signal handlers. It aborts upon receipt of a > > blocked signal. On "CYGWIN_NT-10.0 2.7.0(0.306/5/3) 2017-02-12 13:18 x86_64", > > signals regularly arrive despite being blocked. Essential parts of the > > program include handling two signal numbers and having handlers run for at > > least 1-2ms; this problem goes away if I remove one of those attributes. > > GNU/Linux, AIX, Solaris, and "CYGWIN_NT-6.0 1.7.27(0.271/5/3) 2013-12-09 11:57 > > i686" never deliver a blocked signal to this program. I think this Cygwin > > behavior is non-conforming. > I do not think that Cygwin is the problem here; your code is the problem > here, I believe. > > Please, study, for example, chapters 20 and 21 of LPI (Linux Programming > Interface by Michael Kerrisk). > > (20.10 The Signal Mask (Blocking Signal Delivery) > (20.13 Changing Signal Dispositions: sigaction()) > > You cannot use sigprocmask() like you do; you cannot use SIG_SETMASK as > a parameter in sigprocmask() within the context of a handler. What words in those chapters prompted your conclusion? I see nothing in 20.10 or 20.13 about contextual restrictions on SIG_SETMASK. Posix mentions no such restrictions in its sigprocmask() page, and Posix does say: The following table defines a set of functions that shall be async-signal-safe. Therefore, applications can call them, without restriction, from signal-catching functions. ... sigprocmask() -- http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html > Cygwin exhibits misbehaviour in case of your code, because it is slower > than Linux; however, the code is also wrong for Linux. > > The misbehaviour occurs as result of nested interrupts in case of your > code (yes, nested interrupts are possible with Linux/Unix!). > However your code does not experience nesting under Linux, because, as > I said, Linux is faster than Cygwin. My code *does* experience signal handler nesting on Linux. In fact, handlers nest far more quickly than they do under Cygwin. However, all its nesting under Linux takes place outside the sigprocmask()-bounded critical section. The algorithm that inspired this test case tolerates that nesting, but it does not tolerate nesting within the critical section. > The simplest way to exclude one signal from another, is to specify the > signal (or signals) in the sa_mask of the sigaction parameter ... That is true. However, as you discovered in your other thread, it is not an effective workaround for $SUBJECT. nm -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple