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

os: support Process.Signal(Interrupt) on Windows #46345

Closed
insomnimus opened this issue May 24, 2021 · 4 comments
Closed

os: support Process.Signal(Interrupt) on Windows #46345

insomnimus opened this issue May 24, 2021 · 4 comments
Labels
FeatureRequest FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows
Milestone

Comments

@insomnimus
Copy link

What version of Go are you using (go version)?

$ go version
go version devel go1.17-cca23a7373 Sat May 22 00:51:17 2021 +0000 windows/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=D:\home\.go\bin
set GOCACHE=C:\Users\insomnia\AppData\Local\go-build
set GOENV=C:\Users\insomnia\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=D:\home\.go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=D:\home\.go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=devel go1.17-cca23a7373 Sat May 22 00:51:17 2021 +0000
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\insomnia\AppData\Local\Temp\go-build4037608551=/tmp/go-build -gno-record-gcc-switches

What did you do?

What did you expect to see?

os.Process.Signal(os.Interrupt) should work on windows.

What did you see instead?

In the documentation for os.Process.Signal(), it says that sending os.Interrupt is not implemented on Windows.

It's not an insignificant bit of functionality, i think it should be implemented unless there's an obvious reason to not do so.
Currently this makes it difficult to manage exec.Cmd's properly on Windows.

@mattn
Copy link
Member

mattn commented May 24, 2021

Windows does not have signal feature as same as UNIX one. CTRL-C as you typed on command prompt does not send signal to the process. It is treated as key events. To simulate UNIX's CTLR-C on Windows, we have to use GenerateConsoleCtrlEvent. However, the API does not work with detatched process. i.e. we can regard the CtrlEvent as os.Interrupt but it won't be same behavior.

@mknyszek mknyszek changed the title os: implement *Process.Signal(Interrupt) on Windows os/exec: support os.Process.Signal(Interrupt) on Windows May 24, 2021
@mknyszek mknyszek added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows labels May 24, 2021
@mknyszek mknyszek added this to the Backlog milestone May 24, 2021
@mknyszek
Copy link
Contributor

mknyszek commented May 24, 2021

As @mattn points out, I think this might be impossible. See #6720 for a more complete discussion. It was closed once that documentation was written.

@mknyszek
Copy link
Contributor

Closing on the assumption that this isn't possible, but CCing @ianlancetaylor (via https://dev.golang.org/owners) and @alexbrainman (who was involved in #6720) just in case.

@mknyszek mknyszek changed the title os/exec: support os.Process.Signal(Interrupt) on Windows os: support Process.Signal(Interrupt) on Windows May 24, 2021
@alexbrainman
Copy link
Member

I just re-read #6720 again. And, indeed, we can implement os.Interrupt (by using Windows Ctrl-Break) but we can only send it to a "console process group" which sometimes is OK, but generally is not possible. See #6720 (comment)

Alex

@golang golang locked and limited conversation to collaborators May 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FeatureRequest FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows
Projects
None yet
Development

No branches or pull requests

5 participants