Browse Source

use golang.org/x/sys on ppc64, ppc64le

close #19
Yasuhiro Matsumoto 8 years ago
parent
commit
34aedb9539
3 changed files with 20 additions and 2 deletions
  1. 1 1
      isatty_linux.go
  2. 18 0
      isatty_linux_ppc64.go
  3. 1 1
      isatty_others.go

+ 1 - 1
isatty_linux.go

@@ -1,5 +1,5 @@
 // +build linux
 // +build linux
-// +build !appengine
+// +build !appengine,!ppc64,!ppc64le
 
 
 package isatty
 package isatty
 
 

+ 18 - 0
isatty_linux_ppc64.go

@@ -0,0 +1,18 @@
+// +build linux,ppc64
+
+package isatty
+
+import (
+	"unsafe"
+
+	syscall "golang.org/x/sys/unix"
+)
+
+const ioctlReadTermios = syscall.TCGETS
+
+// IsTerminal return true if the file descriptor is terminal.
+func IsTerminal(fd uintptr) bool {
+	var termios syscall.Termios
+	_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
+	return err == 0
+}

+ 1 - 1
isatty_others.go

@@ -1,5 +1,5 @@
 // +build !windows
 // +build !windows
-// +build !appengine
+// +build !appengine,!ppc64,!ppc64le
 
 
 package isatty
 package isatty