From ab31d0ec5bfaaf0084ffadf468932440c019224a Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Fri, 3 May 2024 22:20:45 +0200 Subject: Fix shutdown of config monitor This implements a coordinated shutdown of the config monitor by sending an event to its thread and waiting for the thread to terminate. --- alacritty/src/main.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'alacritty/src/main.rs') diff --git a/alacritty/src/main.rs b/alacritty/src/main.rs index 2a60961a..f9301767 100644 --- a/alacritty/src/main.rs +++ b/alacritty/src/main.rs @@ -56,7 +56,8 @@ mod gl { #[cfg(unix)] use crate::cli::MessageOptions; use crate::cli::{Options, Subcommands}; -use crate::config::{monitor, UiConfig}; +use crate::config::monitor::ConfigMonitor; +use crate::config::UiConfig; use crate::event::{Event, Processor}; #[cfg(target_os = "macos")] use crate::macos::locale; @@ -165,8 +166,10 @@ fn alacritty(mut options: Options) -> Result<(), Box> { // // The monitor watches the config file for changes and reloads it. Pending // config changes are processed in the main loop. + let mut config_monitor = None; if config.live_config_reload { - monitor::watch(config.config_paths.clone(), window_event_loop.create_proxy()); + config_monitor = + ConfigMonitor::new(config.config_paths.clone(), window_event_loop.create_proxy()); } // Create the IPC socket listener. @@ -205,8 +208,10 @@ fn alacritty(mut options: Options) -> Result<(), Box> { // FIXME: Change PTY API to enforce the correct drop order with the typesystem. drop(processor); - // FIXME patch notify library to have a shutdown method. - // config_reloader.join().ok(); + // Terminate the config monitor. + if let Some(config_monitor) = config_monitor.take() { + config_monitor.shutdown(); + } // Without explicitly detaching the console cmd won't redraw it's prompt. #[cfg(windows)] -- cgit