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.
6 // +build linux darwin freebsd openbsd netbsd dragonfly
18 // IsTerminal returns true if stderr's file descriptor is a terminal.
19 func IsTerminal(f io.Writer) bool {
21 switch v := f.(type) {
23 _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(v.Fd()), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)