mirror of
https://github.com/golang/term.git
synced 2026-01-29 07:02:06 +03:00
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 <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Avelino <t@avelino.xxx> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
committed by
Ian Lance Taylor
parent
073b14d8cc
commit
5cd87de7cc
4
util.go
4
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user