Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Commit

Permalink
Fix build on Solaris/illumos.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Jonathan Perkin committed Apr 11, 2022
1 parent 459523e commit 8a89add
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
6 changes: 3 additions & 3 deletions terminal/runereader_posix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -56,15 +56,15 @@ 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
}

return nil
}

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
Expand Down
14 changes: 14 additions & 0 deletions terminal/runereader_unix.go
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 8a89add

Please sign in to comment.