From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.134]) by sourceware.org (Postfix) with ESMTPS id 50CDB3858D37 for ; Mon, 6 Jul 2020 18:21:03 +0000 (GMT) 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@cygwin.com Received: from calimero.vinschen.de ([217.91.18.234]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1N8XgH-1kwHYC48Sf-014Xk7 for ; Mon, 06 Jul 2020 20:21:02 +0200 Received: by calimero.vinschen.de (Postfix, from userid 500) id 84DB0A80705; Mon, 6 Jul 2020 20:21:01 +0200 (CEST) Date: Mon, 6 Jul 2020 20:21:01 +0200 From: Corinna Vinschen To: cygwin@cygwin.com Subject: Re: SIGINT lost while program calls PeekMessage Message-ID: <20200706182101.GH514059@calimero.vinschen.de> Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com References: <02c901d65397$9c49fcf0$d4ddf6d0$@beniston.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 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: notjunk:1;V03:K0:lce5zWkPvos=:36Wf2xXgVc8Wd/tmS6Nc2J lwe0jAZuAv+eKWlfu3tNDEYp5wTS71xMOGL5kxcHmdOFcSPZ7Iv0ed8rziSo8suOKu6OChfmU riVO+vZamqI1x9v3iTTHZP1reiNwNj9FB4e1R6e264FKCORV7DrJfLLeZFkF4AQVNy/tUHBfn uppTuQV0KBnIC5klJ78CrKsDgKyyVHTFogFW/ztzrKDdiudDFx1Bi6EPM2/04hVS8NdQkgCvA tU7uZ5xIexOejJ4ONgt+492NQhSwBNmrBZOOZtzvbFPY9jIYbIvW+0PcgRtODX/efSSQNOuuB eToCXdy4zrFCjxXFnwnSM+vFhwTT+xhfpDj7CLTI2yEClzFgrXdLUS3U8jkkmab0AcR/Pavj2 wK1kVzvTkjA0iydmjJ3UPIaBe3KlBbhgk8FSavmfnWLUcd4sZNjspvRkODegwtD+Iu4oMRWzv nHFZQiDVBfezAhJhCw1ySBHSqJy1fky0Qxb/52UcRRLTel0amCmBSyB3YDrRszfoESqPq0wjU E4zT9hZ5Xw+SoOlFJjurP2/vvXjHNbyqYLT/dKGbuWX1LQbH7D6/4MH8xPUwUq+v10lzGGsz+ W/wATKpMtLPQZ0XT4PUE8VlaKeyXqcwB9Q3hBA4HLgzcSAECoYn5JakbYtp1rk54OF424KGcj /NHsuJqFKnynCFrcnh2PqW0zKcdLWtCaSixRwZcSgYUwDsoxuYSDXatwSsz1zGtOojHTPpHan PFK4f6Wy7UHwXCootvkzAtfIilRPjdPXA7h55DsXCigJ0iaTzJsSzGYuKy8lfZIhsvkQz0X5T oXhr1bNhHi8zn9d6+3xSbl3kv94k2c9Y/N+MTO4HmT59LSNNmXTQh/w/GiYV00x6EZlwpzDAI 6a8W61FBTBd2wqaM+B1w== X-Spam-Status: No, score=-98.2 required=5.0 tests=BAYES_00, GOOD_FROM_CORINNA_CYGWIN, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_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@cygwin.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: , X-List-Received-Date: Mon, 06 Jul 2020 18:21:04 -0000 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