Skip to content

os, runtime: CTRL_CLOSE_EVENT should generate SIGHUP on Windows #6948

@anacrolix

Description

@anacrolix
On Windows, the CTRL_C_EVENT and CTRL_BREAK_EVENT control signals are converted to
SIGINT in the runtime package for Windows for use by the os/signal package. After some
investigation, I believe CTRL_CLOSE_EVENT should be emulated as SIGHUP. SIGHUP is
already invented for compatibility purposes in the syscall package, in the same way that
SIGINT is, and then actively used by the existing handlers installed for CTRL_C_EVENT
and CTRL_BREAK_EVENT above.

Relevant lines in tip's source:

runtime·stdcall(runtime·SetConsoleCtrlHandler, 2, runtime·ctrlhandler, (uintptr)1);
// This registers Go's control event handler to convert control events into unix-like
signals

/* in the handler these events are converted to SIGINT */
    case CTRL_C_EVENT:
    case CTRL_BREAK_EVENT:
        s = SIGINT;

/* invented values for important signals */
    SIGHUP  = Signal(0x1)
    SIGINT  = Signal(0x2)

Please also see:

http://stackoverflow.com/q/20511182/149482
http://msdn.microsoft.com/en-us/library/windows/desktop/ms685049%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/ms683242(v=vs.85).aspx

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-WindowsSuggestedIssues that may be good for new contributors looking for work to do.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions