From 4585fc05455cfbafb24e2ad27be745b7a520cab7 Mon Sep 17 00:00:00 2001 From: victor Date: Thu, 14 Mar 2019 19:06:36 +0900 Subject: [PATCH] =?UTF-8?q?STDIN=20=EC=97=90=EC=BD=94=20=EB=B9=84=ED=99=9C?= =?UTF-8?q?=EC=84=B1=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go/src/fullcycle/analog-kernel/main.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/go/src/fullcycle/analog-kernel/main.go b/go/src/fullcycle/analog-kernel/main.go index ecb5ae4..61e4df0 100644 --- a/go/src/fullcycle/analog-kernel/main.go +++ b/go/src/fullcycle/analog-kernel/main.go @@ -10,9 +10,14 @@ import ( "os" "strings" + "golang.org/x/sys/unix" + "fullcycle/analog-kernel/parser" ) +const ioctlReadTermios = unix.TCGETS +const ioctlWriteTermios = unix.TCSETS + const defaultResult = ` { "result": { @@ -73,6 +78,17 @@ func init() { } func main() { + // Disable echo for stdin. + termios, err := unix.IoctlGetTermios(0, ioctlReadTermios) + check(err) + + termios.Lflag &= ^(uint32(unix.ECHO | unix.ICANON)) + termios.Cc[unix.VMIN] = 1 + termios.Cc[unix.VTIME] = 0 + + err = unix.IoctlSetTermios(0, ioctlWriteTermios, termios) + check(err) + var r parser.Request // Read the sheet. -- 2.1.4