blob: 1f0c6bf53dceae4332245f746ee401dce78c3edf [file] [log] [blame]
David K. Bainbridge528b3182017-01-23 08:51:59 -08001// +build solaris
2// +build !appengine
3
4package isatty
5
6import (
7 "golang.org/x/sys/unix"
8)
9
10// IsTerminal returns true if the given file descriptor is a terminal.
11// see: http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libbc/libc/gen/common/isatty.c
12func IsTerminal(fd uintptr) bool {
13 var termio unix.Termio
14 err := unix.IoctlSetTermio(int(fd), unix.TCGETA, &termio)
15 return err == nil
16}