From f0b09a1382ff5bf7a2b15ef2d4131e0595d78d23 Mon Sep 17 00:00:00 2001 From: Dmytro Kozlov Date: Tue, 21 Mar 2023 16:53:53 +0200 Subject: [PATCH] app/vmctl: follow up after aed59b90298a6b5e44ffea4543a6aa3b9e402e65 (#3983) --- app/vmctl/terminal/terminal.go | 10 +--------- app/vmctl/terminal/unix.go | 5 +++++ app/vmctl/terminal/unix_bsd.go | 5 +++++ app/vmctl/terminal/windows..go | 8 ++++++++ 4 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 app/vmctl/terminal/windows..go diff --git a/app/vmctl/terminal/terminal.go b/app/vmctl/terminal/terminal.go index 2f3e26eaa..6b3f9ad85 100644 --- a/app/vmctl/terminal/terminal.go +++ b/app/vmctl/terminal/terminal.go @@ -1,14 +1,6 @@ -//go:build darwin || linux || solaris -// +build darwin linux solaris - package terminal -import ( - "golang.org/x/sys/unix" -) - // IsTerminal returns true if the file descriptor is terminal func IsTerminal(fd int) bool { - _, err := unix.IoctlGetTermios(fd, ioctlReadTermios) - return err == nil + return isTerminal(fd) } diff --git a/app/vmctl/terminal/unix.go b/app/vmctl/terminal/unix.go index 610e17f8c..ad8e64b07 100644 --- a/app/vmctl/terminal/unix.go +++ b/app/vmctl/terminal/unix.go @@ -6,3 +6,8 @@ package terminal import "golang.org/x/sys/unix" const ioctlReadTermios = unix.TCGETS + +func isTerminal(fd int) bool { + _, err := unix.IoctlGetTermios(fd, ioctlReadTermios) + return err == nil +} diff --git a/app/vmctl/terminal/unix_bsd.go b/app/vmctl/terminal/unix_bsd.go index 7f866d087..6e5ebae0e 100644 --- a/app/vmctl/terminal/unix_bsd.go +++ b/app/vmctl/terminal/unix_bsd.go @@ -6,3 +6,8 @@ package terminal import "golang.org/x/sys/unix" const ioctlReadTermios = unix.TIOCGETA + +func isTerminal(fd int) bool { + _, err := unix.IoctlGetTermios(fd, ioctlReadTermios) + return err == nil +} diff --git a/app/vmctl/terminal/windows..go b/app/vmctl/terminal/windows..go new file mode 100644 index 000000000..c3af23e40 --- /dev/null +++ b/app/vmctl/terminal/windows..go @@ -0,0 +1,8 @@ +//go:build windows +// +build windows + +package terminal + +func isTerminal(fd int) bool { + return true +}