vendor/github.com/mattn/go-isatty/isatty_bsd.go
changeset 251 1c52a0eeb952
parent 242 2a9ec03fe5a1
child 260 445e01aede7e
equal deleted inserted replaced
250:c040f992052f 251:1c52a0eeb952
     1 // +build darwin freebsd openbsd netbsd dragonfly
     1 // +build darwin freebsd openbsd netbsd dragonfly
     2 // +build !appengine
     2 // +build !appengine
     3 
     3 
     4 package isatty
     4 package isatty
     5 
     5 
     6 import (
     6 import "golang.org/x/sys/unix"
     7 	"syscall"
       
     8 	"unsafe"
       
     9 )
       
    10 
       
    11 const ioctlReadTermios = syscall.TIOCGETA
       
    12 
     7 
    13 // IsTerminal return true if the file descriptor is terminal.
     8 // IsTerminal return true if the file descriptor is terminal.
    14 func IsTerminal(fd uintptr) bool {
     9 func IsTerminal(fd uintptr) bool {
    15 	var termios syscall.Termios
    10 	_, err := unix.IoctlGetTermios(int(fd), unix.TIOCGETA)
    16 	_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
    11 	return err == nil
    17 	return err == 0
       
    18 }
    12 }
       
    13 
       
    14 // IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
       
    15 // terminal. This is also always false on this environment.
       
    16 func IsCygwinTerminal(fd uintptr) bool {
       
    17 	return false
       
    18 }