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