12 lines
252 B
Go
Raw Permalink Normal View History

2025-02-16 17:28:10 +01:00
//go:build darwin || freebsd
2024-03-12 00:25:20 +01:00
package tty
2024-03-12 15:23:08 +01:00
import "golang.org/x/sys/unix"
2024-03-12 00:25:20 +01:00
// IsTerminal returns true if the file descriptor is a terminal.
func IsTerminal(fd uintptr) bool {
2024-03-12 15:23:08 +01:00
_, err := unix.IoctlGetTermios(int(fd), unix.TIOCGETA)
return err == nil
2024-03-12 00:25:20 +01:00
}