-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Description
TL;DR: Posted to go-nuts, and Ian Lance Taylor responded:
I think this is a bug. (*File).readFrom, or perhaps NewSyscallError,
should convert poll.ErrFileClosing to os.ErrClosed, just as
(*File).wrapErr does.
I believe they're referring to this line in os/readfrom_linux.go.
What version of Go are you using (go version)?
$ go version go version go1.18.10 linux/amd64
Does this issue reproduce with the latest release?
Don't know.
What operating system and processor architecture are you using (go env)?
go env Output
$ go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/home/runner/.cache/go-build" GOENV="/home/runner/.config/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/home/runner/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/runner/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/opt/hostedtoolcache/go/1.18.10/x64" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/opt/hostedtoolcache/go/1.18.10/x64/pkg/tool/linux_amd64" GOVCS="" GOVERSION="go1.18.10" GCCGO="gccgo" GOAMD64="v1" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/home/runner/work/gosh/gosh/go.mod" GOWORK="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build918714692=/tmp/go-build -gno-record-gcc-switches"
What did you do?
My code is essentially running shell pipelines, and i want to catch harmless errors where a process on the left side of the pipeline dies because the right side has finished. Think { echo 1; echo 2; echo 3; } | head -n1.
So in addition to catching EPIPEs and SIGPIPEs, i catch file closed errors:
// ignore writes to closed pipe
switch err := err.(type) {
case *fs.PathError:
if err.Op == "write" && err.Path == "|1" && errors.Is(err.Err, fs.ErrClosed) {
return nil
}
}
return errWhat did you expect to see?
Nothing.
What did you see instead?
Code dies with the error message write |1: copy_file_range: use of closed file. Since this error appears to be internal/poll.ErrFileClosing, i can't catch it since i can't import the package.