diff --git a/pkg/eval/port.go b/pkg/eval/port.go index 3ba7f9ab..a633395c 100644 --- a/pkg/eval/port.go +++ b/pkg/eval/port.go @@ -6,7 +6,6 @@ import ( "io" "os" "sync" - "syscall" "src.elv.sh/pkg/eval/errs" "src.elv.sh/pkg/eval/vals" @@ -292,7 +291,7 @@ func (bo byteOutput) WriteString(s string) (int, error) { func convertReaderGone(err error) error { if pathErr, ok := err.(*os.PathError); ok { - if pathErr.Err == syscall.EPIPE { + if pathErr.Err == epipe { return errs.ReaderGone{} } } diff --git a/pkg/eval/port_unix.go b/pkg/eval/port_unix.go new file mode 100644 index 00000000..76dfcdea --- /dev/null +++ b/pkg/eval/port_unix.go @@ -0,0 +1,7 @@ +//+build !windows,!plan9,!js + +package eval + +import "syscall" + +var epipe = syscall.EPIPE diff --git a/pkg/eval/port_windows.go b/pkg/eval/port_windows.go new file mode 100644 index 00000000..a2759d55 --- /dev/null +++ b/pkg/eval/port_windows.go @@ -0,0 +1,10 @@ +package eval + +import "syscall" + +// Error number 232 is what Windows returns when trying to write on a pipe who +// reader has gone. The syscall package defines an EPIPE on Windows, but that's +// not what Windows API actually returns. +// +// https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499- +var epipe = syscall.Errno(232)