mirror of
https://github.com/golang/go
synced 2024-11-17 10:44:43 -07:00
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 <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>
This commit is contained in:
parent
964985362b
commit
4f5859c046
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user