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

CTRL_CLOSE_EVENT #2

Open
judwhite opened this issue May 9, 2016 · 1 comment
Open

CTRL_CLOSE_EVENT #2

judwhite opened this issue May 9, 2016 · 1 comment

Comments

@judwhite
Copy link
Owner

judwhite commented May 9, 2016

Here's how to catch CTRL_CLOSE_EVENT in Windows (end task or close console window). There was some effort to translate this to SIGTERM but requires blocking which isn't compatible with the signal.Notify model.

The right way to stop a service would be sc stop or net stop and I believe these stop signals are sent during reboot/shutdown, I'll have to double check. If they are this is probably just "interesting" and adding this would help in the case of someone killing the process instead of stopping the service gracefully.

@judwhite
Copy link
Owner Author

This issue may be resolved by Go 1.14:

On Windows, the CTRL_CLOSE_EVENT, CTRL_LOGOFF_EVENT, and CTRL_SHUTDOWN_EVENT events now generate a syscall.SIGTERM signal, similar to how Control-C and Control-Break generate a syscall.SIGINT signal.

https://golang.org/doc/go1.14#os/signal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant