terminal_solaris.go 387 B

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