File: terminal_notwindows.go

package info (click to toggle)
golang-logrus 0.8.7-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 284 kB
  • ctags: 303
  • sloc: sh: 41; makefile: 6
file content (21 lines) | stat: -rw-r--r-- 575 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Based on ssh/terminal:
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// +build linux darwin freebsd openbsd netbsd dragonfly

package logrus

import (
	"syscall"
	"unsafe"
)

// IsTerminal returns true if the given file descriptor is a terminal.
func IsTerminal() bool {
	fd := syscall.Stdout
	var termios Termios
	_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
	return err == 0
}