mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-05 03:17:50 +08:00
pkg/eval: Fix EPIPE on Windows.
The syscall package exposes an EPIPE on Windows, but it's not what Windows APIs return. The error number 232 is what is semantically EPIPE.
This commit is contained in:
parent
53dbece608
commit
6ced40733c
|
@ -6,7 +6,6 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
"syscall"
|
|
||||||
|
|
||||||
"src.elv.sh/pkg/eval/errs"
|
"src.elv.sh/pkg/eval/errs"
|
||||||
"src.elv.sh/pkg/eval/vals"
|
"src.elv.sh/pkg/eval/vals"
|
||||||
|
@ -292,7 +291,7 @@ func (bo byteOutput) WriteString(s string) (int, error) {
|
||||||
|
|
||||||
func convertReaderGone(err error) error {
|
func convertReaderGone(err error) error {
|
||||||
if pathErr, ok := err.(*os.PathError); ok {
|
if pathErr, ok := err.(*os.PathError); ok {
|
||||||
if pathErr.Err == syscall.EPIPE {
|
if pathErr.Err == epipe {
|
||||||
return errs.ReaderGone{}
|
return errs.ReaderGone{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
7
pkg/eval/port_unix.go
Normal file
7
pkg/eval/port_unix.go
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
//+build !windows,!plan9,!js
|
||||||
|
|
||||||
|
package eval
|
||||||
|
|
||||||
|
import "syscall"
|
||||||
|
|
||||||
|
var epipe = syscall.EPIPE
|
10
pkg/eval/port_windows.go
Normal file
10
pkg/eval/port_windows.go
Normal file
|
@ -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)
|
Loading…
Reference in New Issue
Block a user