From ff63344b7e396170cb7bb619bbed404268deaf90 Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Fri, 17 Jun 2022 01:33:47 +0300 Subject: Ignore special files for live config reload When using `--config-file /dev/null` with `live_config_reload`, each write to `/dev/null` was forcing alacritty to reload its configuration. This commit makes alacritty ignore special files for live config reload. Co-authored-by: Christian Duerr --- alacritty/src/config/mod.rs | 4 +++- alacritty/src/config/monitor.rs | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'alacritty/src') diff --git a/alacritty/src/config/mod.rs b/alacritty/src/config/mod.rs index 10e504d3..df49db31 100644 --- a/alacritty/src/config/mod.rs +++ b/alacritty/src/config/mod.rs @@ -2,7 +2,7 @@ use std::fmt::{self, Display, Formatter}; use std::path::{Path, PathBuf}; use std::{env, fs, io}; -use log::{error, info}; +use log::{debug, error, info}; use serde::Deserialize; use serde_yaml::mapping::Mapping; use serde_yaml::Value; @@ -125,6 +125,8 @@ pub fn load(options: &Options) -> UiConfig { /// Attempt to reload the configuration file. pub fn reload(config_path: &Path, options: &Options) -> Result { + debug!("Reloading configuration file: {:?}", config_path); + // Load config, propagating errors. let config_options = options.config_options.clone(); let mut config = load_from(config_path, config_options)?; diff --git a/alacritty/src/config/monitor.rs b/alacritty/src/config/monitor.rs index 63f7549f..305f5dfb 100644 --- a/alacritty/src/config/monitor.rs +++ b/alacritty/src/config/monitor.rs @@ -21,6 +21,13 @@ pub fn watch(mut paths: Vec, event_proxy: EventLoopProxy) { return; } + // Exclude char devices like `/dev/null`, sockets, and so on, by checking that file type is a + // regular file. + paths.retain(|path| { + // Call `metadata` to resolve symbolink links. + path.metadata().map_or(false, |metadata| metadata.file_type().is_file()) + }); + // Canonicalize paths, keeping the base paths for symlinks. for i in 0..paths.len() { if let Ok(canonical_path) = paths[i].canonicalize() { -- cgit