From 5cd87de7cccf6e7ec10bef8cb3dbfc472de3b52c Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Mon, 7 Aug 2017 12:11:13 +0200 Subject: [PATCH] ssh/terminal: set termios VMIN and VTIME in MakeRaw The Solaris version of MakeRaw already sets VMIN and VTIME explicitly such that a read returns when one character is available. cfmakeraw (whose behavior MakeRaw replicate) in glibc and the BSD's libc also set these values explicitly, so it should be done in the Linux/BSD versions of MakeRaw as well to be consistent. Change-Id: I531641ec87fd6a21b7a544b9a464bb90045b0bb1 Reviewed-on: https://go-review.googlesource.com/53570 Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot Reviewed-by: Avelino Reviewed-by: Ian Lance Taylor --- util.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/util.go b/util.go index d019196..e7404ff 100644 --- a/util.go +++ b/util.go @@ -19,6 +19,8 @@ package terminal // import "golang.org/x/crypto/ssh/terminal" import ( "syscall" "unsafe" + + "golang.org/x/sys/unix" ) // State contains the state of a terminal. @@ -50,6 +52,8 @@ func MakeRaw(fd int) (*State, error) { newState.Lflag &^= syscall.ECHO | syscall.ECHONL | syscall.ICANON | syscall.ISIG | syscall.IEXTEN newState.Cflag &^= syscall.CSIZE | syscall.PARENB newState.Cflag |= syscall.CS8 + newState.Cc[unix.VMIN] = 1 + newState.Cc[unix.VTIME] = 0 if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlWriteTermios, uintptr(unsafe.Pointer(&newState)), 0, 0, 0); err != 0 { return nil, err }