From d8a53fbafddae72ef98095a9efeb228eb3ffd32c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 15 Jan 2024 21:27:22 +0530 Subject: [PATCH] Retry on temp errors when reading from terminal --- tools/cmd/benchmark/main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/cmd/benchmark/main.go b/tools/cmd/benchmark/main.go index dac608ffc..ef3064313 100644 --- a/tools/cmd/benchmark/main.go +++ b/tools/cmd/benchmark/main.go @@ -4,6 +4,7 @@ package benchmark import ( "bytes" + "errors" "fmt" "math/rand" "strings" @@ -17,6 +18,7 @@ import ( "kitty/tools/utils" "golang.org/x/exp/slices" + "golang.org/x/sys/unix" ) var _ = fmt.Print @@ -101,6 +103,9 @@ func benchmark_data(description string, data string, opts Options) (duration tim for !bytes.Contains(read_data, q) { n, err := term.Read(buf) if err != nil { + if (errors.Is(err, unix.EAGAIN) || errors.Is(err, unix.EINTR)) && n == 0 { + continue + } break } read_data = append(read_data, buf[:n]...)