On Fri, Sep 26, 2014 at 6:08 PM, Si Robertson <
retrom...@gmail.com> wrote:
> I'm using the signals documented in the Go package reference
> (
http://golang.org/pkg/os/#Signal), and the code is based on the provided
> example. Apparently those signals are guaranteed to be present on all
> systems but the docs do not say those signals are guaranteed to be caught
> (received by the Go app).
>
> In "normal" apps created with C/C++ etc we would be dealing with a message
> pump or a console CTRL handler, at least on Windows systems.
>
> It looks like this is going to require platform-specific code in the Go app
> as I mentioned previously.
>
If I'm reading the sources correctly, on Windows, signals are emulated
by SetConsoleCtrlHandler (see
https://code.google.com/p/go/source/browse/src/runtime/os_windows.c#484
). It handles CTRL_C_EVENT and CTRL_BREAK_EVENT as SIGINT.
Closing the console window sends a CTRL_CLOSE_EVENT and gives the
program 5 seconds before killing it. As far as I can tell, the Go
runtime doesn't handle CTRL_CLOSE_EVENT. Perhaps it should handle it
as SIGHUP or some other signal?