blob: 3c86b1abeeb19fcae94b5def7cfb80fab1e0ebe9 [file] [log] [blame]
David K. Bainbridge215e0242017-09-05 23:18:24 -07001// +build solaris,!appengine
2
3package logrus
4
5import (
6 "io"
7 "os"
8
9 "golang.org/x/sys/unix"
10)
11
12// IsTerminal returns true if the given file descriptor is a terminal.
13func IsTerminal(f io.Writer) bool {
14 switch v := f.(type) {
15 case *os.File:
16 _, err := unix.IoctlGetTermios(int(v.Fd()), unix.TCGETA)
17 return err == nil
18 default:
19 return false
20 }
21}