Skip to content

x/sys/windows: signal.Notify doesn't handle windows.Signal well #70369

@QianQQQ

Description

@QianQQQ

Go version

go version go1.22.3 windows/amd64

Output of go env in your module/workspace:

set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\qian\AppData\Local\go-build
set GOENV=C:\Users\qian\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\qian\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\qian\go
set GOPRIVATE=
set GOROOT=D:\Environments\go
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=D:\Environments\go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.22.3
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=0
set GOMOD=NUL
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\qian\AppData\Local\Temp\go-build3528663502=/tmp/go-build -gno-record-gcc-switches

What did you do?

When developing a server on Windows, we want to capture the SIGINT signal for extension purposes.
https://go.dev/play/p/wiNlThXDUPT

What did you see happen?

signal.Notify(c chan<- os.Signal, sig ...os.Signal) cannot correctly capture windows.Signal.

What did you expect to see?

signal.Notify can correctly handle windows.Signal.
This means that when pressing Ctrl+C, the logic can be correctly triggered.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.OS-WindowsThinkingcompiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    Status

    No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions