소스 검색

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>
Tobias Klauser 8 년 전
부모
커밋
eb71ad9bd3
1개의 변경된 파일4개의 추가작업 그리고 0개의 파일을 삭제
  1. 4 0
      ssh/terminal/util.go

+ 4 - 0
ssh/terminal/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
 	}