blob: 42f2514d1338e43fef753492e70c99460d8ce7e3 [file] [log] [blame]
David K. Bainbridge528b3182017-01-23 08:51:59 -08001// +build darwin freebsd openbsd netbsd dragonfly
2// +build !appengine
3
4package isatty
5
6import (
7 "syscall"
8 "unsafe"
9)
10
11const ioctlReadTermios = syscall.TIOCGETA
12
13// IsTerminal return true if the file descriptor is terminal.
14func IsTerminal(fd uintptr) bool {
15 var termios syscall.Termios
16 _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
17 return err == 0
18}