-
Notifications
You must be signed in to change notification settings - Fork 293
Rework process shutdown (fixes #3235) #7404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The signal handler installed currently is prone to crashing as it logs from within the signal handler which may end up corrupting the memory allocator. Replace it with a process tracker: * shut down the application using chronos' waitSignal when available * avoid allocating memory in signal handler * track and print shutdown reason
8eb2e58
to
3a27b37
Compare
If you dont need to support SIGTERM on Windows, what the reason to support SIGTERM on Posix? |
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/signal?view=msvc-170
https://man7.org/linux/man-pages/man1/kill.1.html
|
And you found one more reason why using The only way how And if you check this function documentation you will find that If we will use your specific example of https://github.com/status-im/nim-chronos/blob/master/chronos/internal/asyncengine.nim#L507-L525 |
#7404 attempted to use `waitSignal` to handle shutdown notifications but this turned out to be unreliable, in particular due to multi-threading and cross-platform differences. This PR fixes the crash in signal handlers by removing logging but otherwise retains the polling nature of the shutdown initiation - it also allows nimbus eth1/2 to share the same cross-thread mechanism for initiating a shutdown.
Draft pending status-im/nim-chronos#581 |
#7404 attempted to use `waitSignal` to handle shutdown notifications but this turned out to be unreliable, in particular due to multi-threading and cross-platform differences. This PR fixes the crash in signal handlers by removing logging but otherwise retains the polling nature of the shutdown initiation - it also allows nimbus eth1/2 to share the same cross-thread mechanism for initiating a shutdown.
Rebase of #7404 following the adoption of #7418. When using chronos to terminate the process, we run into various threading and cross-platform issues captured in status-im/nim-chronos#581, specially in `nimbus` which has a more complex threading picture.
The signal handler installed currently is prone to crashing as it logs from within the signal handler which may end up corrupting the memory allocator.
Replace it with a process tracker: