另客网go项目公用的代码库

isatty_android.go 370B

123456789101112131415161718
  1. // +build android
  2. package isatty
  3. import (
  4. "syscall"
  5. "unsafe"
  6. )
  7. const ioctlReadTermios = syscall.TCGETS
  8. // IsTerminal return true if the file descriptor is terminal.
  9. func IsTerminal(fd uintptr) bool {
  10. var termios syscall.Termios
  11. _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
  12. return err == 0
  13. }