|
6 | 6 | "os"
|
7 | 7 | "path/filepath"
|
8 | 8 | "strings"
|
9 |
| - "syscall" |
10 | 9 |
|
11 | 10 | "github.com/crc-org/vfkit/pkg/config"
|
12 | 11 | "github.com/onsi/gocleanup"
|
@@ -232,21 +231,19 @@ func unixFd(fd uintptr) int {
|
232 | 231 | // https://developer.apple.com/documentation/virtualization/running_linux_in_a_virtual_machine#3880009
|
233 | 232 | func setRawMode(f *os.File) error {
|
234 | 233 | // Get settings for terminal
|
235 |
| - attr, _ := unix.IoctlGetTermios(unixFd(f.Fd()), unix.TIOCGETA) |
| 234 | + var attr unix.Termios |
| 235 | + err := termios.Tcgetattr(f.Fd(), &attr) |
| 236 | + if err != nil { |
| 237 | + return err |
| 238 | + } |
236 | 239 |
|
237 | 240 | // Put stdin into raw mode, disabling local echo, input canonicalization,
|
238 | 241 | // and CR-NL mapping.
|
239 |
| - attr.Iflag &^= syscall.ICRNL |
240 |
| - attr.Lflag &^= syscall.ICANON | syscall.ECHO |
241 |
| - |
242 |
| - // Set minimum characters when reading = 1 char |
243 |
| - attr.Cc[syscall.VMIN] = 1 |
244 |
| - |
245 |
| - // set timeout when reading as non-canonical mode |
246 |
| - attr.Cc[syscall.VTIME] = 0 |
| 242 | + attr.Iflag &^= unix.ICRNL |
| 243 | + attr.Lflag &^= unix.ICANON | unix.ECHO |
247 | 244 |
|
248 | 245 | // reflects the changed settings
|
249 |
| - return unix.IoctlSetTermios(unixFd(f.Fd()), unix.TIOCSETA, attr) |
| 246 | + return termios.Tcsetattr(f.Fd(), termios.TCSANOW, &attr) |
250 | 247 | }
|
251 | 248 |
|
252 | 249 | func (dev *VirtioSerial) toVz() (*vz.VirtioConsoleDeviceSerialPortConfiguration, error) {
|
|
0 commit comments