]> Cypherpunks repositories - gostls13.git/commitdiff
os: don't check for TTY before calling splice
authorIan Lance Taylor <iant@golang.org>
Thu, 16 Mar 2023 19:14:03 +0000 (12:14 -0700)
committerGopher Robot <gobot@golang.org>
Thu, 16 Mar 2023 19:34:54 +0000 (19:34 +0000)
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 <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
src/os/readfrom_linux.go

index c67407cf66ed6b83c18f0ee1d202701f3774ad34..7e8024028e98e852d7787845e8a94732f88e8cd4 100644 (file)
@@ -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