From: Ian Lance Taylor Date: Thu, 16 Mar 2023 19:14:03 +0000 (-0700) Subject: os: don't check for TTY before calling splice X-Git-Tag: go1.21rc1~1244 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=4f5859c0467a6e252e4705cd0086aaef6904e5a4;p=gostls13.git 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 Auto-Submit: Ian Lance Taylor Reviewed-by: Bryan Mills Run-TryBot: Ian Lance Taylor TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor --- diff --git a/src/os/readfrom_linux.go b/src/os/readfrom_linux.go index c67407cf66..7e8024028e 100644 --- a/src/os/readfrom_linux.go +++ b/src/os/readfrom_linux.go @@ -33,19 +33,6 @@ func (f *File) readFrom(r io.Reader) (written int64, handled bool, err error) { } func (f *File) spliceToFile(r io.Reader) (written int64, handled bool, err error) { - // At least as of kernel 5.19.11, splice to a tty fails. - // poll.Splice will do the wrong thing if it can splice from r - // but can't splice to f: it will read data from r, which is - // not what we want if r is a pipe or socket. - // So we have to check now whether f is a tty. - fi, err := f.Stat() - if err != nil { - return 0, false, err - } - if fi.Mode()&ModeCharDevice != 0 { - return 0, false, nil - } - var ( remain int64 lr *io.LimitedReader