mirror of
https://github.com/golang/go
synced 2024-11-22 00:24:41 -07:00
syscall: handle EOF on pipe - special case on Windows
R=rsc CC=golang-dev https://golang.org/cl/962046
This commit is contained in:
parent
ac1d46a22a
commit
b94ae26073
@ -184,6 +184,10 @@ func Open(path string, mode int, perm int) (fd int, errno int) {
|
||||
func Read(fd int, p []byte) (n int, errno int) {
|
||||
var done uint32
|
||||
if ok, e := ReadFile(int32(fd), p, &done, nil); !ok {
|
||||
if e == ERROR_BROKEN_PIPE {
|
||||
// BUG(brainman): work around ERROR_BROKEN_PIPE is returned on reading EOF from stdin
|
||||
return 0, 0
|
||||
}
|
||||
return 0, e
|
||||
}
|
||||
return int(done), 0
|
||||
|
@ -8,6 +8,7 @@ package syscall
|
||||
const (
|
||||
ERROR_FILE_NOT_FOUND = 2
|
||||
ERROR_NO_MORE_FILES = 18
|
||||
ERROR_BROKEN_PIPE = 109
|
||||
ERROR_INSUFFICIENT_BUFFER = 122
|
||||
ERROR_MOD_NOT_FOUND = 126
|
||||
ERROR_PROC_NOT_FOUND = 127
|
||||
|
Loading…
Reference in New Issue
Block a user