2024-03-11 23:25:20 +00:00
|
|
|
package tty
|
|
|
|
|
2024-03-12 14:23:08 +00:00
|
|
|
import "golang.org/x/sys/unix"
|
|
|
|
|
2024-03-11 23:25:20 +00:00
|
|
|
// IsTerminal returns true if the file descriptor is a terminal.
|
|
|
|
func IsTerminal(fd uintptr) bool {
|
2024-03-12 14:23:08 +00:00
|
|
|
_, err := unix.IoctlGetTermios(int(fd), unix.TIOCGETA)
|
|
|
|
return err == nil
|
2024-03-11 23:25:20 +00:00
|
|
|
}
|