github.com/btwiuse/jiri@v0.0.0-20191125065820-53353bcfef54/isatty/isatty.go (about)

     1  // Copyright 2017 The Fuchsia Authors. 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  // +build linux darwin
     6  
     7  package isatty
     8  
     9  import (
    10  	"os"
    11  	"syscall"
    12  	"unsafe"
    13  )
    14  
    15  func IsTerminal() bool {
    16  	var termios syscall.Termios
    17  	_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, os.Stdout.Fd(), ioctlTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
    18  	return err == 0
    19  }