12 lines
238 B
Go
Raw Normal View History

2025-02-16 17:28:10 +01:00
//go:build linux
2024-03-12 00:25:20 +01:00
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
}