Add Windows shutdown handler#13131
Conversation
src/init.cpp
Outdated
There was a problem hiding this comment.
What does sleeping a negative amount of time do?
There was a problem hiding this comment.
Sleep as long as possible and wait for main thread quit.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
INFINITE is 0xFFFFFFFF, so it might be the same. But to be safe, I would change it to the macro.
|
utACK ddebde7 |
|
Will test shortly. |
|
@jonasschnelli Could you spin up a Windows build for this PR? |
|
Thanks. I think this was long overdue. Gitian Build: https://bitcoin.jonasschnelli.ch/build/591 |
There was a problem hiding this comment.
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.
ddebde7 Add Windows shutdown handler (Chun Kuan Lee) Pull request description: Exit properly when clicked the red X of Windows Console Tree-SHA512: f030edd08868390662b42abfa1dc6bd702166c6c19f5b1f8e7482e202451e79fb6f37ea672c26c2eb0d32c367bfca86160fbee624696c53828f280b7070be6a0
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. |
GitHub-Pull: bitcoin#13131 Rebased-From: ddebde7
|
Added to #13455 for backport. |
9fd3e00 depends: Update Qt download url (fanquake) f7401c8 Fix parameter count check for importpubkey. (Kristaps Kaupe) cbd2f70 expose CBlockIndex::nTx in getblock(header) (Gregory Sanders) ce8aa54 Add Windows shutdown handler (Chun Kuan Lee) 18b0c69 Bugfix: Include <memory> for std::unique_ptr (Luke Dashjr) Pull request description: Backports: * #12859 Bugfix: Include <memory> for std::unique_ptr * #13131 Add Windows shutdown handler * #13451 rpc: expose CBlockIndex::nTx in getblock(header) * #13507 RPC: Fix parameter count check for importpubkey * #13544 depends: Update Qt download url to the 0.16 branch. Tree-SHA512: eeaec52d001d5c81e67dda3a2d3fee7a9445e569366e597b18e81d802c1b7f89e545afd53d094740c37c1714050304979398b9860144454d3a5cb5abc9e9eaca
GitHub-Pull: bitcoin#13131 Rebased-From: ddebde7
ddebde7 Add Windows shutdown handler (Chun Kuan Lee) Pull request description: Exit properly when clicked the red X of Windows Console Tree-SHA512: f030edd08868390662b42abfa1dc6bd702166c6c19f5b1f8e7482e202451e79fb6f37ea672c26c2eb0d32c367bfca86160fbee624696c53828f280b7070be6a0
Exit properly when clicked the red X of Windows Console