From 989a803a5ba2ea787d3178fd918671e11a5a1871 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Loi=CC=88c=20Carr?= Date: Sat, 24 Mar 2018 12:40:32 +0100 Subject: [PATCH] Replace SYS_IOCTL by cross platform version --- arch.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/arch.go b/arch.go index d856fbd..77a4dea 100644 --- a/arch.go +++ b/arch.go @@ -5,10 +5,10 @@ package gottyclient import ( "encoding/json" "fmt" + "golang.org/x/sys/unix" "os" "os/signal" "syscall" - "unsafe" ) func notifySignalSIGWINCH(c chan<- os.Signal) { @@ -20,12 +20,10 @@ func resetSignalSIGWINCH() { } func syscallTIOCGWINSZ() ([]byte, error) { - ws := winsize{} - - syscall.Syscall(syscall.SYS_IOCTL, - uintptr(0), uintptr(syscall.TIOCGWINSZ), - uintptr(unsafe.Pointer(&ws))) - + ws, err := unix.IoctlGetWinsize(0, 0) + if err != nil { + return nil, fmt.Errorf("ioctl error: %v", err) + } b, err := json.Marshal(ws) if err != nil { return nil, fmt.Errorf("json.Marshal error: %v", err)