diff --git a/src/common/os_input_output.rs b/src/common/os_input_output.rs index adde6fdff2..6b849efaba 100644 --- a/src/common/os_input_output.rs +++ b/src/common/os_input_output.rs @@ -275,14 +275,14 @@ impl Clone for Box { } } -pub fn get_server_os_input() -> ServerOsInputOutput { - let current_termios = termios::tcgetattr(0).unwrap(); +pub fn get_server_os_input() -> Result { + let current_termios = termios::tcgetattr(0)?; let orig_termios = Arc::new(Mutex::new(current_termios)); - ServerOsInputOutput { + Ok(ServerOsInputOutput { orig_termios, receive_instructions_from_client: None, send_instructions_to_client: Arc::new(Mutex::new(None)), - } + }) } #[derive(Clone)] @@ -403,12 +403,12 @@ impl Clone for Box { } } -pub fn get_client_os_input() -> ClientOsInputOutput { - let current_termios = termios::tcgetattr(0).unwrap(); +pub fn get_client_os_input() -> Result { + let current_termios = termios::tcgetattr(0)?; let orig_termios = Arc::new(Mutex::new(current_termios)); - ClientOsInputOutput { + Ok(ClientOsInputOutput { orig_termios, send_instructions_to_server: Arc::new(Mutex::new(None)), receive_instructions_from_server: Arc::new(Mutex::new(None)), - } + }) } diff --git a/src/main.rs b/src/main.rs index 49e42ffbfa..12842b58cb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -39,10 +39,22 @@ pub fn main() { atomic_create_dir(&*ZELLIJ_TMP_DIR).unwrap(); atomic_create_dir(&*ZELLIJ_TMP_LOG_DIR).unwrap(); if let Some(path) = opts.server { - let os_input = get_server_os_input(); + let os_input = match get_server_os_input() { + Ok(server_os_input) => server_os_input, + Err(e) => { + eprintln!("failed to open terminal:\n{}", e); + std::process::exit(1); + } + }; start_server(Box::new(os_input), path); } else { - let os_input = get_client_os_input(); + let os_input = match get_client_os_input() { + Ok(os_input) => os_input, + Err(e) => { + eprintln!("failed to open terminal:\n{}", e); + std::process::exit(1); + } + }; start_client(Box::new(os_input), opts, config); } }