Skip to content

Commit 757b080

Browse files
committed
vmm: prevent CR translation to LF in interactive term
Fix a bug where Carriage Return (CR) get's translated into a Line Feed (LF) in interactive terminal use-cases. Fixes: #562 Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
1 parent 9b7c6cb commit 757b080

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/vmm/src/terminal.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use nix::sys::termios::{tcgetattr, tcsetattr, LocalFlags, SetArg, Termios};
1+
use nix::sys::termios::{cfmakeraw, tcgetattr, tcsetattr, LocalFlags, SetArg, Termios};
22
use std::os::fd::BorrowedFd;
33

44
#[must_use]
@@ -12,12 +12,12 @@ pub fn term_set_raw_mode(
1212
let mut termios = tcgetattr(term)?;
1313
let old_state = termios.clone();
1414

15-
let mut mask = LocalFlags::ECHO | LocalFlags::ICANON;
16-
if !handle_signals_by_terminal {
17-
mask |= LocalFlags::ISIG
15+
cfmakeraw(&mut termios);
16+
17+
if handle_signals_by_terminal {
18+
termios.local_flags |= LocalFlags::ISIG;
1819
}
1920

20-
termios.local_flags &= !mask;
2121
tcsetattr(term, SetArg::TCSANOW, &termios)?;
2222
Ok(TerminalMode(old_state))
2323
}

0 commit comments

Comments
 (0)