From 92ace142b4871b86e79673100ec10897119a6f80 Mon Sep 17 00:00:00 2001 From: GarandPLG Date: Mon, 6 Apr 2026 11:10:03 +0200 Subject: [PATCH] Join input thread before exiting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Store the input event thread handle and join it after the app finishes. This replaces the previous fire‑and‑forget spawn and ensures the thread is cleanly terminated before the program exits. --- src/main.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 0c37d88..5412831 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,7 @@ use ratatui::{Terminal, prelude::CrosstermBackend}; use std::{ io::{Result, Stdout}, sync::mpsc::{Sender, channel}, - thread, + thread::{self, JoinHandle}, }; use war_in_tunnels::{ app::{App, AppEvent, handle_input_events}, @@ -27,12 +27,14 @@ fn main() -> Result<()> { let (event_tx, event_rx) = channel::(); let tx_to_input_events: Sender = event_tx.clone(); - thread::spawn(move || { + let input_thread: JoinHandle<()> = thread::spawn(move || { handle_input_events(tx_to_input_events); }); let app_result: Result<()> = app.run(&mut terminal, event_rx); ratatui::restore(); + let _ = input_thread.join(); + app_result }