X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CD595385DC00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1594059666; bh=+C80eWCmz1IddA7AWtaFgSkingZotQ1DqemCtn7J9yA=; h=Date:From:To:Subject:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Reply-To:From; b=jZgF5DgVtmNIElapVGmkdnLmeM9MvNsER+124w3XNY6zrkXjtrCKpKYfA4B8OhJ7U wzi+k96XsbcS1beZCRd3aISVdlr0CBa0mQLo1Sjui1mgLvNXNjwI8r6ndt1gkYFXtM G48CxBv9iBv4N52Zo93lInScRTW7EL73L+/XzD4w= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 50CDB3858D37 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=cygwin.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=corinna-cygwin AT cygwin DOT com Date: Mon, 6 Jul 2020 20:21:01 +0200 From: Corinna Vinschen To: cygwin AT cygwin DOT com Subject: Re: SIGINT lost while program calls PeekMessage Message-ID: <20200706182101.GH514059@calimero.vinschen.de> Mail-Followup-To: cygwin AT cygwin DOT com References: <02c901d65397$9c49fcf0$d4ddf6d0$@beniston.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <02c901d65397$9c49fcf0$d4ddf6d0$@beniston.com> X-Provags-ID: V03:K1:WXi4Qfts3RS+FOklwc6k2P7v2qyZvglmgt6V4xeGsZT2jj3InS8 aeqr73M/19lDRn0v+hBeSxRHwpzxrOKtEGJClIglsp4NLN4yRj+17My//n99R3Em9QfTDRc FC7jfudE8nwqxwiCFv0IDq5D+nkgHBsR69+dTCLrr9tCEetJP3ziKRDgIExjbwhvrHj3zB1 D2b/NTIcSAOgldl8fif4g== X-UI-Out-Filterresults: notjun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NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: cygwin AT cygwin DOT com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: cygwin-bounces AT cygwin DOT com Sender: "Cygwin" On Jul 6 14:16, Jon Beniston wrote: > Hi Corinna, > > >Since your example code is running very tightly most of its time inside > >some Windows system DLL function, there's next to no chance to interrupt > >the thread to inject the signal handler call. Cygwin tries this 100 > >times per signal. If that fails, the signal gets lost. > > > >One way to solve this problem is adding a Cygwin call into the loop, > >like the aforementioned usleep. When a Cygwin call is performed, the > >signal handler will be called as soon as the Cygwin call returns to > >user-space. > > > >The bottom line is, Cygwin user space signal handlers and lots of > >Windows-only calls in a tight loop don't work nicely together. > > Ok, thanks for the explanation. In the real application, there is some > actual processing inside the loop, besides the call to PeekMessage and more > signals get through (Probably 75%), I just cut the code down to make a > simpler test case. I'll add a Cygwin call as suggested. Actually, if the application is using lots of Windows calls and (almost) no Cygwin calls, I'd suggest to drop signals in favor of utilizing the Windows message queue to signal specific states to the executable. As for Cygwin's signal handling, it's a bit finicky in border cases, and the fact that a signal can be queued only once is not very 21st century either. I haven't got a grip on these problems yet, but I'll look into them for sure at one point. Corinna -- Corinna Vinschen Cygwin Maintainer -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple