remove os-specific IsTerminal methods, and use x/crypto/ssh/terminal instead

This commit is contained in:
dmathieu
2017-07-27 14:23:27 +02:00
parent 9aa7601a11
commit e66f22976f
5 changed files with 14 additions and 144 deletions
-29
View File
@@ -1,29 +0,0 @@
// Based on ssh/terminal:
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build linux darwin freebsd openbsd netbsd dragonfly nacl
// +build !appengine
package logrus
import (
"io"
"os"
"unsafe"
"golang.org/x/sys/unix"
)
// IsTerminal returns true if stderr's file descriptor is a terminal.
func IsTerminal(f io.Writer) bool {
var termios Termios
switch v := f.(type) {
case *os.File:
_, _, err := unix.Syscall6(unix.SYS_IOCTL, uintptr(v.Fd()), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
return err == 0
default:
return false
}
}