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

main: Support SIGTERM on Win and all unix variants. #381

Merged
merged 1 commit into from Sep 18, 2023

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Sep 18, 2023

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

It also pulls in the logic from dcrd so that logging is added when a signal is received so it is clear why the process is being shutdown.

@davecgh davecgh force-pushed the signal branch 2 times, most recently from 6e35673 to a3557ad Compare September 18, 2023 12:42
dcrpool.go Outdated Show resolved Hide resolved
dcrpool.go Outdated Show resolved Hide resolved
dcrpool.go Show resolved Hide resolved
signal.go Show resolved Hide resolved
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 dcrpool 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.

It also pulls in the logic from dcrd so that logging is added when a
signal is received so it is clear why the process is being shutdown.
@jholdstock jholdstock merged commit 89a2ed8 into decred:master Sep 18, 2023
2 checks passed
@davecgh davecgh deleted the signal branch September 18, 2023 17:08
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