terminal_notwindows.go 595 B

1234567891011121314151617181920212223
  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 darwin freebsd openbsd netbsd dragonfly
  6. // +build !appengine
  7. package logrus
  8. import (
  9. "syscall"
  10. "unsafe"
  11. )
  12. // IsTerminal returns true if stderr's file descriptor is a terminal.
  13. func IsTerminal() bool {
  14. fd := syscall.Stderr
  15. var termios Termios
  16. _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
  17. return err == 0
  18. }