Add Windows shutdown handler #13131

pull ken2812221 wants to merge 1 commits into bitcoin:master from ken2812221:win-quit changing 1 files +11 −0
  1. ken2812221 commented at 4:54 pm on April 30, 2018: contributor
    Exit properly when clicked the red X of Windows Console
  2. MarcoFalke added the label Windows on Apr 30, 2018
  3. 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 constant INFINITE 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.
  4. Add Windows shutdown handler ddebde71ef
  5. ken2812221 force-pushed on May 1, 2018
  6. laanwj commented at 11:53 am on May 1, 2018: member
    utACK ddebde71efe17eb3b1367948e9b728f6a86696ab
  7. fanquake commented at 12:49 pm on May 1, 2018: member
    Will test shortly.
  8. fanquake commented at 3:11 am on May 2, 2018: member
    @jonasschnelli Could you spin up a Windows build for this PR?
  9. 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

  10. donaloconnor approved
  11. 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.

  12. laanwj merged this on May 7, 2018
  13. laanwj closed this on May 7, 2018

  14. laanwj referenced this in commit 57aae632e2 on May 7, 2018
  15. 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.

  16. 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.

  17. ken2812221 deleted the branch on May 7, 2018
  18. laanwj added this to the milestone 0.16.2 on May 28, 2018
  19. laanwj added the label Needs backport on May 28, 2018
  20. fanquake referenced this in commit ce8aa5491f on Jun 13, 2018
  21. fanquake commented at 0:02 am on June 26, 2018: member
    Added to #13455 for backport.
  22. fanquake removed the label Needs backport on Jun 26, 2018
  23. laanwj referenced this in commit dac5374cce on Jul 9, 2018
  24. HashUnlimited referenced this in commit b2e5de4738 on Jan 11, 2019
  25. PastaPastaPasta referenced this in commit 9457c98f52 on Apr 7, 2020
  26. PastaPastaPasta referenced this in commit 11b6221b80 on Apr 8, 2020
  27. ckti referenced this in commit 33df15bd5a on Mar 28, 2021
  28. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-17 15:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me