package main
import (
"fmt"
"os"
"syscall"
)
func main() {
p := &os.Process{Pid: os.Getpid()}
err := p.Signal(syscall.SIGWINCH)
fmt.Println("error:", err)
}
With 1.22 this works without issue. As of https://go.dev/cl/570036, this prints error: bad file descriptor.
The problem is that 0 is a valid value of os.Process.handle, so the Signal method tries to use it as a pidfd.
This is easy to fix with an additional field to report whether handle is initialized (N.B. that handle could really be FD 0, so we can't just look for 0). I will send a CL.
(As far as I know, this form of using os.Process has never worked on Windows, as it always uses the handle field.)
cc @kolyshkin
Comment From: gopherbot
Change https://go.dev/cl/588675 mentions this issue: os: overhaul handling of PID vs pidfd within Process