diff --git a/devices/src/virtio/vhost/user/device/console.rs b/devices/src/virtio/vhost/user/device/console.rs index 5aadd909c0..c3b76401d4 100644 --- a/devices/src/virtio/vhost/user/device/console.rs +++ b/devices/src/virtio/vhost/user/device/console.rs @@ -326,14 +326,16 @@ pub fn run_console_device(program_name: &str, args: &[&str]) -> anyhow::Result<( stdin: true, }; - if let Err(e) = run_console(¶ms, &socket) { - bail!("error occurred: {:#}", e); - } + let res = run_console(¶ms, &socket); // Restore terminal capabilities back to what they were before stdin() .set_canon_mode() .context("Failed to restore canonical mode for terminal")?; + if let Err(e) = res { + bail!("error occurred: {:#}", e); + } + Ok(()) }