10 lines
222 B
Go
Raw Normal View History

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
}