Skip to content

Commit

Permalink
virtme-ng-init: properly configure terminal line settings
Browse files Browse the repository at this point in the history
Make sure to redirect stdout/stderr to the right console before
applying the proper terminal settings via stty.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
  • Loading branch information
Andrea Righi committed Mar 15, 2024
1 parent ea04e35 commit aeaac80
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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) {
Expand Down

0 comments on commit aeaac80

Please sign in to comment.