diff options
author | Alex Brainman <alex.brainman@gmail.com> | 2010-04-30 12:46:46 -0700 |
---|---|---|
committer | Alex Brainman <alex.brainman@gmail.com> | 2010-04-30 12:46:46 -0700 |
commit | 33fbdec01b3f5a47db2e66938d3001c913e9d658 (patch) | |
tree | f1e5a901a056e8776137d395301125d737cca3ca | |
parent | 0ecd377f5c375280b56b1d670ab7e78f99ff574b (diff) | |
download | golang-33fbdec01b3f5a47db2e66938d3001c913e9d658.tar.gz |
syscall: handle EOF on pipe - special case on Windows
R=rsc
CC=golang-dev
http://codereview.appspot.com/962046
Committer: Russ Cox <rsc@golang.org>
-rw-r--r-- | src/pkg/syscall/syscall_windows.go | 4 | ||||
-rw-r--r-- | src/pkg/syscall/zerrors_windows_386.go | 1 |
2 files changed, 5 insertions, 0 deletions
diff --git a/src/pkg/syscall/syscall_windows.go b/src/pkg/syscall/syscall_windows.go index ec889f9e6..401b0a51a 100644 --- a/src/pkg/syscall/syscall_windows.go +++ b/src/pkg/syscall/syscall_windows.go @@ -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 diff --git a/src/pkg/syscall/zerrors_windows_386.go b/src/pkg/syscall/zerrors_windows_386.go index d8b22846c..e96c81703 100644 --- a/src/pkg/syscall/zerrors_windows_386.go +++ b/src/pkg/syscall/zerrors_windows_386.go @@ -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 |