David K. Bainbridge | 528b318 | 2017-01-23 08:51:59 -0800 | [diff] [blame^] | 1 | // +build linux |
2 | // +build !appengine | ||||
3 | |||||
4 | package isatty | ||||
5 | |||||
6 | import ( | ||||
7 | "syscall" | ||||
8 | "unsafe" | ||||
9 | ) | ||||
10 | |||||
11 | const ioctlReadTermios = syscall.TCGETS | ||||
12 | |||||
13 | // IsTerminal return true if the file descriptor is terminal. | ||||
14 | func 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 | } |