Skip to content

Commit 4f5859c

Browse files
ianlancetaylorgopherbot
authored andcommitted
os: don't check for TTY before calling splice
I think I confused myself in CL 476335. The TTY check did fix the problem with os.Stdout, but it was still possible to get the same problem in other ways. I fixed that by making the splice call blocking, but it turns out that doing that is enough to fix the TTY problem also. So we can just remove the TTY check. Fixes #59041 Change-Id: I4d7ca9dad8361001edb4cfa96bb29b1badb54df0 Reviewed-on: https://go-review.googlesource.com/c/go/+/477035 Run-TryBot: Ian Lance Taylor <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> Reviewed-by: Bryan Mills <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 9649853 commit 4f5859c

File tree

1 file changed

+0
-13
lines changed

1 file changed

+0
-13
lines changed

src/os/readfrom_linux.go

-13
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,6 @@ func (f *File) readFrom(r io.Reader) (written int64, handled bool, err error) {
3333
}
3434

3535
func (f *File) spliceToFile(r io.Reader) (written int64, handled bool, err error) {
36-
// At least as of kernel 5.19.11, splice to a tty fails.
37-
// poll.Splice will do the wrong thing if it can splice from r
38-
// but can't splice to f: it will read data from r, which is
39-
// not what we want if r is a pipe or socket.
40-
// So we have to check now whether f is a tty.
41-
fi, err := f.Stat()
42-
if err != nil {
43-
return 0, false, err
44-
}
45-
if fi.Mode()&ModeCharDevice != 0 {
46-
return 0, false, nil
47-
}
48-
4936
var (
5037
remain int64
5138
lr *io.LimitedReader

0 commit comments

Comments
 (0)