delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
X-Original-To: | cygwin AT cygwin DOT com |
Delivered-To: | cygwin AT cygwin DOT com |
DMARC-Filter: | OpenDMARC Filter v1.3.2 sourceware.org CF8E6386F80F |
Authentication-Results: | sourceware.org; |
dmarc=none (p=none dis=none) header.from=beniston.com | |
Authentication-Results: | sourceware.org; spf=none smtp.mailfrom=jon AT beniston DOT com |
X-Session-Marker: | 6A6F6E4062656E6973746F6E2E636F6D |
X-Spam-Summary: | 2, 0, 0, , d41d8cd98f00b204, jon AT beniston DOT com, , |
RULES_HIT:10:41:355:379:541:542:871:968:973:988:989:1000:1155:1260:1308:1309:1313:1314:1345:1381:1437:1516:1518:1534:1540:1575:1587:1594:1711:1730:1747:1764:1777:1792:2110:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:3866:3867:3868:3870:3871:3872:3874:4184:4250:4605:5007:6119:6261:6506:6747:6748:7281:7861:7875:8660:8957:10004:10394:10400:10848:11232:11604:11658:11914:12297:12555:12679:12895:13071:13148:13230:13439:13972:14096:14180:14659:14827:21060:21063:21080:21212:21433:21627:21789:21809:21917:21939:30054:30075, | |
0, RBL:none, CacheIP:none, Bayesian:0.5, 0.5, 0.5, Netcheck:none, | |
DomainCache:0, MSF:not bulk, SPF:, MSBL:0, DNSBL:none, Custom_rules:0:0:0, | |
LFtime:1, LUA_SUMMARY:none | |
X-HE-Tag: | fight52_39116c526e8a |
X-Filterd-Recvd-Size: | 3998 |
From: | "Jon Beniston" <jon AT beniston DOT com> |
To: | <cygwin AT cygwin DOT com> |
Subject: | SIGINT lost while program calls PeekMessage |
Date: | Thu, 2 Jul 2020 17:16:10 +0100 |
Message-ID: | <01ea01d6508c$1a340a70$4e9c1f50$@beniston.com> |
MIME-Version: | 1.0 |
X-Mailer: | Microsoft Outlook 16.0 |
Thread-Index: | AdZQjBkPk3P57jVVTjKjlf3Tv/9Y1w== |
X-Spam-Status: | No, score=1.0 required=5.0 tests=BAYES_40, KAM_DMARC_STATUS, |
KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, | |
RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, | |
SPF_NONE autolearn=no autolearn_force=no version=3.4.2 | |
X-Spam-Level: | * |
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 |
List-Id: | General Cygwin discussions and problem reports <cygwin.cygwin.com> |
List-Archive: | <https://cygwin.com/pipermail/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-request AT cygwin DOT com?subject=help> |
List-Subscribe: | <http://cygwin.com/mailman/listinfo/cygwin>, |
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe> | |
Sender: | "Cygwin" <cygwin-bounces AT cygwin DOT com> |
This is a multipart message in MIME format. ------=_NextPart_000_01EB_01D65094.7BF89980 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi, I have a Cygwin program that: - registers a SIGINT handler, via signal(SIGINT,h) - creates a window, using Win32 CreateWindow - and is then calling PeekMessage for that window in a loop It appears that while PeekMessage is being called, any SIGINTs sent to the program are lost. Is this to be expected as it's not really supported or a bug? To reproduce: - Compile and run the attached example program, and repeatedly press CTRL-C in the console. - Only maybe 1 of every 10 or 20 times CTRL-C is pressed, is the signal handler called. - Similarly, running 'kill -SIGINT PID' results in most of the signals being ignored. - Remove the call to PeekMessage, and the signals are received. Cheers, Jon Windows 10 Professional Ver 10.0 Build 18363 Cygwin DLL version info: DLL version: 3.1.5 ------=_NextPart_000_01EB_01D65094.7BF89980 Content-Type: application/octet-stream; name="sigint_example.c" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="sigint_example.c" #include <signal.h> #include <stdio.h> #include <windows.h> int cnt; HWND window; volatile int x =3D 0; void ctrl_c_handler(int x) { signal(SIGINT, ctrl_c_handler); printf("sig=3D%d cnt=3D%d\n", x, ++cnt); } LRESULT CALLBACK window_proc(HWND hWnd, UINT message, WPARAM wParam, = LPARAM lParam) { switch (message)=20 { case WM_DESTROY: PostQuitMessage(0); x=3D1; break; =20 default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; } void create_win() { HINSTANCE hInstance; WNDCLASSEX wcex;=20 =20 hInstance =3D GetModuleHandle(NULL); =20 wcex.cbSize =3D sizeof(wcex); wcex.style =3D CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc =3D window_proc; wcex.cbClsExtra =3D 0; wcex.cbWndExtra =3D 0; wcex.hInstance =3D hInstance; wcex.hIcon =3D LoadIcon(NULL, IDI_APPLICATION); wcex.hCursor =3D LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground =3D (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName =3D NULL; wcex.lpszClassName =3D "CtrlCWin"; wcex.hIconSm =3D NULL; =20 if (RegisterClassEx(&wcex)) { =20 window =3D CreateWindow("CtrlCWin", "CtrlCWin", = WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 270, 230, = NULL,=20 NULL, hInstance, NULL); if (window)=20 { ShowWindow(window, SW_SHOW); UpdateWindow(window); } } } int main() { MSG msg; BOOL bRet; signal(SIGINT, ctrl_c_handler); =20 create_win(); while(!x) { /* If this call to PeekMessage is removed, signals get through */=20 while (PeekMessage(&msg, window, 0, 0, PM_NOREMOVE))=20 { bRet =3D GetMessage(&msg, window, 0, 0); if (bRet > 0)=20 { =20 TranslateMessage(&msg); DispatchMessage(&msg); } =20 } =20 } return 0; } ------=_NextPart_000_01EB_01D65094.7BF89980 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline -- 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 ------=_NextPart_000_01EB_01D65094.7BF89980--
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |