-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: os Process.Kill() not working on windows #51151
Comments
The Instead, look up the desired PID using |
We expected this to work because it was working in 1.16.14, so 1.17 breaks backwards compatibility. This seems to be the change that broke us 105c5b5?diff=split . When I run with the function
execution succeeds. Source Code: https://go.dev/play/p/mELlwQqiBZa (Note: When we run os.FindProcess on 1.16 and 1.17 it returns "OpenProcess: Access is denied." for our processes) |
Writing process := os.Process{
Pid: pid,
} was never supposed to work. I'm sorry that it did. |
In this case, it should have been documented that it cannot work. While there are unexported members, it isn't immediately clear from the docs that Kill will not work. |
To me it seems clear from the documentation which explicitly says that |
What version of Go are you using (
go version
)?Tested with go version 1.17, 1.17.1, 1.17.3, 1.17.6, and 1.17.7
The feature is working on 1.16.14 and earlier.
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputGOOS="windows" GOARCH="amd64"
What did you do?
I created a small script to use to kill particular processes on windows. When I compile and run the executable though I get the error
DuplicateHandle: The handle is invalid.
Source code: https://go.dev/play/p/Ik3UMsABNQI
What did you expect to see?
Expected Process.Kill to kill the running process without error
What did you see instead?
DuplicateHandle: The handle is invalid.
The text was updated successfully, but these errors were encountered: