From 5d12163091875dd342503f9e885b137f133eb7c3 Mon Sep 17 00:00:00 2001 From: Alexandre Courbot Date: Fri, 4 Feb 2022 17:31:31 +0900 Subject: [PATCH] devices: vhost-user: console: always restore terminal capabilities We used to bail early if an error happened while we run the console device, leaving the terminal in raw mode. BUG=None TEST=cargo build Change-Id: I3dc4a681f736246548d1cc7b7eab0bfd429587be Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3439667 Reviewed-by: Keiichi Watanabe Tested-by: kokoro Commit-Queue: Alexandre Courbot --- devices/src/virtio/vhost/user/device/console.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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(()) }