blob: 98ffe86a4bac9c244fce2bad8fad6bd5f11b4964 [file] [log] [blame]
David K. Bainbridge215e0242017-09-05 23:18:24 -07001// +build darwin freebsd openbsd netbsd
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}