VictoriaMetrics/app/vmctl/terminal/terminal.go
Dmytro Kozlov 8da9502df6
app/vmctl: automatically check tty (#3938)
app/vmctl: automatically detect if TTY is available
2023-03-20 11:16:08 +01:00

15 lines
293 B
Go

//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
}