Add Windows shutdown handler #13131
pull ken2812221 wants to merge 1 commits into bitcoin:master from ken2812221:win-quit changing 1 files +11 −0-
ken2812221 commented at 4:54 pm on April 30, 2018: contributorExit properly when clicked the red X of Windows Console
-
MarcoFalke added the label Windows on Apr 30, 2018
-
in src/init.cpp:315 in f5220fc312 outdated
307@@ -307,6 +308,14 @@ static void HandleSIGHUP(int) 308 { 309 fReopenDebugLog = true; 310 } 311+#else 312+static BOOL WINAPI consoleCtrlHandler(DWORD dwCtrlType) 313+{ 314+ fRequestShutdown = true; 315+ Sleep(-1);
laanwj commented at 10:54 am on May 1, 2018:What does sleeping a negative amount of time do?
ken2812221 commented at 11:00 am on May 1, 2018:Sleep as long as possible and wait for main thread quit.
laanwj commented at 11:29 am on May 1, 2018:I’ve checked MSDN docs: https://msdn.microsoft.com/en-us/library/windows/desktop/ms686298(v=vs.85).aspx and the parameter is a DWORD (unsigned) to -1 is not a valid value. It seems that there is a constantINFINITE
to wait infinitely, if that is what is the intent?
ken2812221 commented at 11:37 am on May 1, 2018:INFINITE is 0xFFFFFFFF, so it might be the same. But to be safe, I would change it to the macro. -
Add Windows shutdown handler ddebde71ef
-
ken2812221 force-pushed on May 1, 2018
-
laanwj commented at 11:53 am on May 1, 2018: memberutACK ddebde71efe17eb3b1367948e9b728f6a86696ab
-
fanquake commented at 12:49 pm on May 1, 2018: memberWill test shortly.
-
fanquake commented at 3:11 am on May 2, 2018: member@jonasschnelli Could you spin up a Windows build for this PR?
-
jonasschnelli commented at 6:53 am on May 2, 2018: contributor
Thanks. I think this was long overdue. utACK ddebde71efe17eb3b1367948e9b728f6a86696ab
Gitian Build: https://bitcoin.jonasschnelli.ch/build/591
-
donaloconnor approved
-
donaloconnor commented at 8:58 pm on May 5, 2018: contributor
tACK ddebde7
I had this change also but didn’t get around to submitting it :-)
This works generally but CTRL_CLOSE_EVENT times out after 5 seconds on my OS (Win10) if the main thread hasn’t ended gracefully. At that point all threads are terminated.
-
laanwj merged this on May 7, 2018
-
laanwj closed this on May 7, 2018
-
laanwj referenced this in commit 57aae632e2 on May 7, 2018
-
laanwj commented at 12:35 pm on May 7, 2018: member
This works generally but CTRL_CLOSE_EVENT times out after 5 seconds on my OS (Win10) if the main thread hasn’t ended gracefully. At that point all threads are terminated.
I guess there’s nothing to be done against that, and it’s the same as on UNIX. Every OS has a timeout after which it loses patience and really terminates a process during shutdown.
-
donaloconnor commented at 12:58 pm on May 7, 2018: contributor
I guess there’s nothing to be done against that, and it’s the same as on UNIX. Every OS has a timeout after which it loses patience and really terminates a process during shutdown
Indeed! Just putting there for FYI really.
-
ken2812221 deleted the branch on May 7, 2018
-
laanwj added this to the milestone 0.16.2 on May 28, 2018
-
laanwj added the label Needs backport on May 28, 2018
-
fanquake referenced this in commit ce8aa5491f on Jun 13, 2018
-
fanquake removed the label Needs backport on Jun 26, 2018
-
laanwj referenced this in commit dac5374cce on Jul 9, 2018
-
HashUnlimited referenced this in commit b2e5de4738 on Jan 11, 2019
-
PastaPastaPasta referenced this in commit 9457c98f52 on Apr 7, 2020
-
PastaPastaPasta referenced this in commit 11b6221b80 on Apr 8, 2020
-
ckti referenced this in commit 33df15bd5a on Mar 28, 2021
-
MarcoFalke locked this on Sep 8, 2021