From eff61a89905f3540067d193b0395e3e785d360e9 Mon Sep 17 00:00:00 2001 From: Andrea Righi Date: Fri, 15 Mar 2024 07:49:12 +0100 Subject: [PATCH] virtme-ng-init: properly configure terminal line settings Make sure to redirect stdout/stderr to the right console before applying the proper terminal settings via stty. Link: https://github.com/arighi/virtme-ng/issues/90 Signed-off-by: Andrea Righi --- src/main.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index b22db05..8cb72d3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -795,6 +795,12 @@ fn redirect_console(consdev: &str) { } fn configure_terminal(consdev: &str, uid: u32) { + // Set proper user ownership on the default console device + utils::do_chown(&consdev, uid, None).ok(); + + // Redirect stdout/stderr to the new console device. + redirect_console(&consdev); + if let Ok(params) = env::var("virtme_stty_con") { let output = Command::new("stty") .args(params.split_whitespace()) @@ -805,11 +811,6 @@ fn configure_terminal(consdev: &str, uid: u32) { .output(); log!("{}", String::from_utf8_lossy(&output.unwrap().stderr)); } - // Set proper user ownership on the default console device - utils::do_chown(&consdev, uid, None).ok(); - - // Redirect stdout/stderr to the new console device. - redirect_console(&consdev); } fn detach_from_terminal(tty_fd: libc::c_int) {