terminal_solaris.go 352 B

12345678910111213141516171819202122
  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. }