color/tty/Terminal_linux.go
2025-06-06 17:05:55 +02:00

11 lines
No EOL
237 B
Go

//go:build linux
package tty
import "golang.org/x/sys/unix"
// IsTerminal returns true if the file descriptor is a terminal.
func IsTerminal(fd uintptr) bool {
_, err := unix.IoctlGetTermios(int(fd), unix.TCGETS)
return err == nil
}