mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-16 21:45:03 +02:00
Retry on temp errors when reading from terminal
This commit is contained in:
@@ -4,6 +4,7 @@ package benchmark
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -17,6 +18,7 @@ import (
|
|||||||
"kitty/tools/utils"
|
"kitty/tools/utils"
|
||||||
|
|
||||||
"golang.org/x/exp/slices"
|
"golang.org/x/exp/slices"
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = fmt.Print
|
var _ = fmt.Print
|
||||||
@@ -101,6 +103,9 @@ func benchmark_data(description string, data string, opts Options) (duration tim
|
|||||||
for !bytes.Contains(read_data, q) {
|
for !bytes.Contains(read_data, q) {
|
||||||
n, err := term.Read(buf)
|
n, err := term.Read(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if (errors.Is(err, unix.EAGAIN) || errors.Is(err, unix.EINTR)) && n == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
read_data = append(read_data, buf[:n]...)
|
read_data = append(read_data, buf[:n]...)
|
||||||
|
|||||||
Reference in New Issue
Block a user