本站源代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
619B

  1. // +build darwin freebsd openbsd netbsd dragonfly
  2. // +build !appengine
  3. package isatty
  4. import (
  5. "syscall"
  6. "unsafe"
  7. )
  8. const ioctlReadTermios = syscall.TIOCGETA
  9. // IsTerminal return true if the file descriptor is terminal.
  10. func IsTerminal(fd uintptr) bool {
  11. var termios syscall.Termios
  12. _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
  13. return err == 0
  14. }
  15. // IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
  16. // terminal. This is also always false on this environment.
  17. func IsCygwinTerminal(fd uintptr) bool {
  18. return false
  19. }
上海开阖软件有限公司 沪ICP备12045867号-1