terminal_notwindows.go 543 B

123456789101112131415161718192021
  1. // Based on ssh/terminal:
  2. // Copyright 2011 The Go Authors. All rights reserved.
  3. // Use of this source code is governed by a BSD-style
  4. // license that can be found in the LICENSE file.
  5. // +build linux,!appengine darwin freebsd openbsd netbsd
  6. package term
  7. import (
  8. "syscall"
  9. "unsafe"
  10. )
  11. // IsTty returns true if the given file descriptor is a terminal.
  12. func IsTty(fd uintptr) bool {
  13. var termios Termios
  14. _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
  15. return err == 0
  16. }