github.com/turingchain2020/turingchain@v1.1.21/common/log/log15/term/terminal_notwindows.go (about) 1 // Copyright Turing Corp. 2018 All Rights Reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Based on ssh/terminal: 6 // Copyright 2011 The Go Authors. All rights reserved. 7 // Use of this source code is governed by a BSD-style 8 // license that can be found in the LICENSE file. 9 10 // +build linux,!appengine darwin freebsd openbsd netbsd 11 12 package term 13 14 import ( 15 "syscall" 16 "unsafe" 17 ) 18 19 // IsTty returns true if the given file descriptor is a terminal. 20 func IsTty(fd uintptr) bool { 21 var termios Termios 22 _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 23 return err == 0 24 }