Commit 4585fc05455cfbafb24e2ad27be745b7a520cab7
1 parent
b4dc09fcaa
Exists in
master
STDIN 에코 비활성화
Showing
1 changed file
with
16 additions
and
0 deletions
Show diff stats
go/src/fullcycle/analog-kernel/main.go
| ... | ... | @@ -10,9 +10,14 @@ import ( |
| 10 | 10 | "os" |
| 11 | 11 | "strings" |
| 12 | 12 | |
| 13 | + "golang.org/x/sys/unix" | |
| 14 | + | |
| 13 | 15 | "fullcycle/analog-kernel/parser" |
| 14 | 16 | ) |
| 15 | 17 | |
| 18 | +const ioctlReadTermios = unix.TCGETS | |
| 19 | +const ioctlWriteTermios = unix.TCSETS | |
| 20 | + | |
| 16 | 21 | const defaultResult = ` |
| 17 | 22 | { |
| 18 | 23 | "result": { |
| ... | ... | @@ -73,6 +78,17 @@ func init() { |
| 73 | 78 | } |
| 74 | 79 | |
| 75 | 80 | func main() { |
| 81 | + // Disable echo for stdin. | |
| 82 | + termios, err := unix.IoctlGetTermios(0, ioctlReadTermios) | |
| 83 | + check(err) | |
| 84 | + | |
| 85 | + termios.Lflag &= ^(uint32(unix.ECHO | unix.ICANON)) | |
| 86 | + termios.Cc[unix.VMIN] = 1 | |
| 87 | + termios.Cc[unix.VTIME] = 0 | |
| 88 | + | |
| 89 | + err = unix.IoctlSetTermios(0, ioctlWriteTermios, termios) | |
| 90 | + check(err) | |
| 91 | + | |
| 76 | 92 | var r parser.Request |
| 77 | 93 | |
| 78 | 94 | // Read the sheet. | ... | ... |