go.fuchsia.dev/jiri@v0.0.0-20240502161911-b66513b29486/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  //go:build linux || darwin
     6  // +build linux darwin
     7  
     8  package isatty
     9  
    10  import (
    11  	"os"
    12  	"syscall"
    13  	"unsafe"
    14  )
    15  
    16  func IsTerminal() bool {
    17  	var termios syscall.Termios
    18  	_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, os.Stdout.Fd(), ioctlTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
    19  	return err == 0
    20  }