-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Closed
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.OS-Windows
Milestone
Description
What version of Go are you using (go version)?
go version devel +1af769d Thu Oct 13 06:16:53 2016 +0000 windows/amd64
What operating system and processor architecture are you using (go env)?
Windows7 64bit
What did you do?
package main
import (
"io"
"log"
"os"
)
func main() {
_, err := io.Copy(os.Stdout, os.Stdin)
if err != nil {
log.Print(err)
}
}What did you expect to see?
break blocking of io.Copy.
What did you see instead?
doesn't break blocking of io.Copy.
I suggest to change like below
diff --git a/src/os/file_windows.go b/src/os/file_windows.go
index ed06b55..ad47ee3 100644
--- a/src/os/file_windows.go
+++ b/src/os/file_windows.go
@@ -233,7 +233,7 @@ func (f *File) readOneUTF16FromConsole() (uint16, error) {
return 0, err
}
if nmb == 0 {
- continue
+ return 0, nil
}
mbytes = append(mbytes, buf[0])
@@ -269,7 +269,7 @@ func (f *File) readConsole(buf []byte) (n int, err error) {
return f.copyReadConsoleBuffer(buf)
}
wchar, err := f.readOneUTF16FromConsole()
- if err != nil {
+ if err != nil || wchar == 0 {
return 0, err
}
r := rune(wchar)I wonder what way is best for go because below's C code work with different behavior to go.
#include <stdio.h>
int
main(int argc, char* argv[]) {
char buf[256];
printf("%d\n", fread(buf, 1, sizeof(buf), stdin));
perror("fread");
return 0;
}Microsoft C runtime seeks break fread when typing CTRL-Z in the beigin of the line. But my patch break even though typing CTRL-Z at end of the line.
I don't say that Go have to work as same as C. But I worry about the right way for go.
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.OS-Windows

