From 8a89add84287059f16f15c3b9d412cebcfd4e96d Mon Sep 17 00:00:00 2001 From: Jonathan Perkin Date: Mon, 11 Apr 2022 13:03:04 +0100 Subject: [PATCH] Fix build on Solaris/illumos. Fill in the missing ioctlReadTermios/ioctlWriteTermios, and switch to syscall.Syscall as Syscall6 is not available. Probably makes this work on AIX too as a bonus. --- terminal/runereader_posix.go | 6 +++--- terminal/runereader_unix.go | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 terminal/runereader_unix.go diff --git a/terminal/runereader_posix.go b/terminal/runereader_posix.go index 3b846049..5957fd91 100644 --- a/terminal/runereader_posix.go +++ b/terminal/runereader_posix.go @@ -44,7 +44,7 @@ func (rr *RuneReader) Buffer() *bytes.Buffer { // For reading runes we just want to disable echo. func (rr *RuneReader) SetTermMode() error { - if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(rr.stdio.In.Fd()), ioctlReadTermios, uintptr(unsafe.Pointer(&rr.state.term)), 0, 0, 0); err != 0 { + if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(rr.stdio.In.Fd()), ioctlReadTermios, uintptr(unsafe.Pointer(&rr.state.term))); err != 0 { return err } @@ -56,7 +56,7 @@ func (rr *RuneReader) SetTermMode() error { newState.Cc[syscall.VMIN] = 1 newState.Cc[syscall.VTIME] = 0 - if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(rr.stdio.In.Fd()), ioctlWriteTermios, uintptr(unsafe.Pointer(&newState)), 0, 0, 0); err != 0 { + if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(rr.stdio.In.Fd()), ioctlWriteTermios, uintptr(unsafe.Pointer(&newState))); err != 0 { return err } @@ -64,7 +64,7 @@ func (rr *RuneReader) SetTermMode() error { } func (rr *RuneReader) RestoreTermMode() error { - if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(rr.stdio.In.Fd()), ioctlWriteTermios, uintptr(unsafe.Pointer(&rr.state.term)), 0, 0, 0); err != 0 { + if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(rr.stdio.In.Fd()), ioctlWriteTermios, uintptr(unsafe.Pointer(&rr.state.term))); err != 0 { return err } return nil diff --git a/terminal/runereader_unix.go b/terminal/runereader_unix.go new file mode 100644 index 00000000..c9f450a1 --- /dev/null +++ b/terminal/runereader_unix.go @@ -0,0 +1,14 @@ +// copied from golang.org/x/term/term_unix_other.go +// Copyright 2021 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. + +//go:build aix || solaris || zos +// +build aix solaris zos + +package terminal + +import "golang.org/x/sys/unix" + +const ioctlReadTermios = unix.TCGETS +const ioctlWriteTermios = unix.TCSETS