terminal_solaris.go 352 B

123456789101112131415161718192021
  1. // +build solaris,!appengine
  2. package logrus
  3. import (
  4. "io"
  5. "os"
  6. "golang.org/x/sys/unix"
  7. )
  8. // IsTerminal returns true if the given file descriptor is a terminal.
  9. func IsTerminal(f io.Writer) bool {
  10. switch v := f.(type) {
  11. case *os.File:
  12. _, err := unix.IoctlGetTermios(int(v.Fd()), unix.TCGETA)
  13. return err == nil
  14. default:
  15. return false
  16. }
  17. }