Source file
src/cmd/dist/test_linux.go
1
2
3
4
5
6
7
8 package main
9
10 import (
11 "syscall"
12 "unsafe"
13 )
14
15 const ioctlReadTermios = syscall.TCGETS
16
17
18 func isTerminal(fd uintptr) bool {
19 var termios syscall.Termios
20 _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
21 return err == 0
22 }
23
24 func init() {
25 stdOutErrAreTerminals = func() bool {
26 return isTerminal(1) && isTerminal(2)
27 }
28 }
29
View as plain text