X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:message-id:references :mime-version:content-type:in-reply-to; q=dns; s=default; b=G/O4 /7PxBFl7lyuKMEt5O/wv4aTrE4lWjlsmslfctcySu0k0Wl9emfnWOQAIoJbo3PsJ b0D0Oo0uVHwZe+2p5WSBsIV4SPYjbZyVsl+kSNysUojrtI8oZzTHbFuX3RVWXcX9 bqDG4CVrvV1pqTlEawCucFD2WGs+GBq+wvFYE8U= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:message-id:references :mime-version:content-type:in-reply-to; s=default; bh=8XYGIdhOF4 ynqd2BcLkPXWG35Tc=; b=oHByzJ5BiqCSby9KT7JN3aLRPgVbQ5NJlgPmjSg7eX +BmAtYKZeesSbvDATJo4GTmdSrLyienUar5ihVbifY8Uu2qOVCSeV6rY4/hrdDVn McejvnWK/0dreEeL8AZA/J4Lr7k+78LgErppP3FbDcz42JbRuM4CTnLo4LKlSeBf I= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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 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) Date: Sat, 19 Aug 2017 01:01:10 -0700 From: Noah Misch To: Houder Cc: cygwin AT cygwin DOT com Subject: Re: Signal delivered while blocked Message-ID: <20170819080110.GA4022431@rfd.leadboat.com> References: <20170804074445 DOT GB3154757 AT rfd DOT leadboat DOT com> <8f7f7f8ae098c1321f608645c750cae4 AT smtp-cloud7 DOT xs4all DOT 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 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