blob: 329038f6ca056a7f6ba7aef9d098fa813d78ece2 [file] [log] [blame]
Jonathan Hartf86817b2018-08-17 10:35:54 -07001// 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// +build linux darwin freebsd openbsd netbsd dragonfly
7// +build !appengine
8
9package logrus
10
11import (
12 "syscall"
13 "unsafe"
14)
15
16// IsTerminal returns true if stderr's file descriptor is a terminal.
17func IsTerminal() bool {
18 fd := syscall.Stderr
19 var termios Termios
20 _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
21 return err == 0
22}