github.com/samgwo/go-ethereum@v1.8.2-0.20180302101319-49bcb5fbd55e/log/term/terminal_notwindows.go (about) 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. 5 6 // +build linux,!appengine darwin freebsd openbsd netbsd 7 8 package term 9 10 import ( 11 "syscall" 12 "unsafe" 13 ) 14 15 // IsTty returns true if the given file descriptor is a terminal. 16 func IsTty(fd uintptr) bool { 17 var termios Termios 18 _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 19 return err == 0 20 }