golang / go

The Go programming language

Home Page:https://go.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

os: ErrProcessDone not defined on windows

qmuntal opened this issue · comments

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

$ go tip

Does this issue reproduce with the latest release?

It reproduces on tip

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

go env Output
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Dante\AppData\Local\go-build
set GOENV=C:\Users\Dante\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\Dante\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\Dante\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Users\Dante\Documents\Code\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Users\Dante\Documents\Code\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\Dante\Documents\Code\helloworld\go.mod
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\Dante\AppData\Local\Temp\go-build704363910=/tmp/go-build -gno-record-gcc-switches  

What did you do?

Use the error os.ErrProcessDone with GOOS=windows, which has just been exported in tip CL 242998.

Playground link: https://play.golang.org/p/OMXQb0DeySn

What did you expect to see?

Code compiling and p.Signal() returning os.ErrProcessDone

What did you see instead?

.\main.go:23:13: undefined: os.ErrProcessDone

It seems that os.ErrProcessDone has only been exported for Unix, even though this same error can also be returned on Windows (see os/exec_windows.go#L64).
It was probably forgotten in CL 242998 because the error was declared as a sentinel error on Unix and inlined on Windows.

I´ve just found that os.ErrProcessDone could also be used on plan9 (see os/exec_plan9.go#L55).

I see that in os/exec_unix.go method signal returns ErrProcessDone but the same function in os/exec_windows.go returns errors.New("os: process already finished").

Is the solution to this issue as simple as exporting the variable ErrProcessDone in os/exec_windows.go and returning this error in appropriate functions?

Change https://golang.org/cl/266997 mentions this issue: os: export ErrProcessDone variable in windows and plan9

Marking as release-blocker because this is a defect in a new API being added in Go 1.16 (#39444).