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.

Link: arighi/virtme-ng#90
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
  • Loading branch information
arighi committed Mar 15, 2024
1 parent ea04e35 commit eff61a8
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/main.rs
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 eff61a8

Please sign in to comment.