Skip to content
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

dcrd: Support SIGTERM on Win and all unix variants. #2958

Merged
merged 1 commit into from Jun 10, 2022

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Jun 3, 2022

Go 1.14 added runtime support for handling the windows CTRL_CLOSE_EVENT, CTRL_LOGOFF_EVENT, and CTRL_SHUTDOWN_EVENT events by adding a definition for syscall.SIGTERM to windows and converting the events to that signal. It also added definitions for other common signals, including SIGHUP, and treats them as NOOPs on windows.

Consequently, this modifies the logic that deals with conditionally handling SIGTERM and SIGHUP to handle them for windows as well as all unix-like operating systems, including newer ones that are supported by Go since the code was originally written.

Although the additional signals could probably just be added unconditionally without too much issue now due to the runtime adding stubs to all operating systems the project officially supports, it is safer to be explicit when dealing with syscall definitions since there is no guarantee that they will exist for newly-added operating systems.

Stated more plainly, this change means dcrd will now be shutdown cleanly on more variants of unix as well as when being terminated by windows itself due to various things such as the user logging off, the window terminal being closed, and the system shutting down.

@davecgh davecgh added this to the 1.8.0 milestone Jun 3, 2022
Go 1.14 added runtime support for handling the windows
CTRL_CLOSE_EVENT, CTRL_LOGOFF_EVENT, and CTRL_SHUTDOWN_EVENT events by
adding a definition for syscall.SIGTERM to windows and converting the
events to that signal.  It also added definitions for other common
signals, including SIGHUP, and treats them as NOOPs on windows.

Consequently, this modifies the logic that deals with conditionally
handling SIGTERM and SIGHUP to handle them for windows as well as all
unix-like operating systems, including newer ones that are supported by
Go since the code was originally written.

Although the additional signals could probably just be added
unconditionally without too much issue now due to the runtime adding
stubs to all operating systems the project officially supports, it is
safer to be explicit when dealing with syscall definitions since there
is no guarantee that they will exist for newly-added operating systems.

Stated more plainly, this change means dcrd will now be shutdown cleanly
on more variants of unix as well as when being terminated by windows
itself due to various things such as the user logging off, the window
terminal being closed, and the system shutting down.
@davecgh davecgh force-pushed the main_support_windows_sigterm branch from 2a4f619 to 1629418 Compare June 10, 2022 18:05
@davecgh davecgh merged commit 1629418 into decred:master Jun 10, 2022
@davecgh davecgh deleted the main_support_windows_sigterm branch June 10, 2022 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants