The stupid term package is not EINTR safe
This commit is contained in:
parent
15e1f376a4
commit
e599a2c87f
2
setup.py
2
setup.py
@ -897,6 +897,8 @@ def update_go_generated_files(args: Options, kitty_exe: str) -> None:
|
|||||||
|
|
||||||
|
|
||||||
def build_kitty_tool(args: Options, launcher_dir: str, for_freeze: bool = False) -> None:
|
def build_kitty_tool(args: Options, launcher_dir: str, for_freeze: bool = False) -> None:
|
||||||
|
sys.stdout.flush()
|
||||||
|
sys.stderr.flush()
|
||||||
go = shutil.which('go')
|
go = shutil.which('go')
|
||||||
if not go:
|
if not go:
|
||||||
raise SystemExit('The go tool was not found on this system. Install Go')
|
raise SystemExit('The go tool was not found on this system. Install Go')
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import (
|
|||||||
"github.com/mattn/go-runewidth"
|
"github.com/mattn/go-runewidth"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
"golang.org/x/term"
|
"golang.org/x/sys/unix"
|
||||||
|
|
||||||
"kitty"
|
"kitty"
|
||||||
"kitty/tools/utils"
|
"kitty/tools/utils"
|
||||||
@ -328,9 +328,16 @@ func full_command_name(cmd *cobra.Command) string {
|
|||||||
func show_usage(cmd *cobra.Command, use_pager bool) error {
|
func show_usage(cmd *cobra.Command, use_pager bool) error {
|
||||||
screen_width := 80
|
screen_width := 80
|
||||||
if stdout_is_terminal {
|
if stdout_is_terminal {
|
||||||
screen_width, _, tty_size_err := term.GetSize(int(os.Stdout.Fd()))
|
var sz *unix.Winsize
|
||||||
if tty_size_err != nil || screen_width > 80 {
|
var tty_size_err error
|
||||||
screen_width = 80
|
for {
|
||||||
|
sz, tty_size_err = unix.IoctlGetWinsize(int(os.Stdout.Fd()), unix.TIOCGWINSZ)
|
||||||
|
if tty_size_err != unix.EINTR {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if tty_size_err == nil && sz.Col < 80 {
|
||||||
|
screen_width = int(sz.Col)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var output strings.Builder
|
var output strings.Builder
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user