From 6075d25f470a1145aa8240e64868cdfebc1dc348 Mon Sep 17 00:00:00 2001 From: Can Celik Date: Sun, 13 Sep 2026 23:37:26 +0300 Subject: fix: keep plugins working after client-only updates (#4077) --- src/platform/linux.rs | 20 ++++++++++++++++++++ src/platform/mod.rs | 5 +++++ 2 files changed, 25 insertions(+) (limited to 'src/platform') diff --git a/src/platform/linux.rs b/src/platform/linux.rs index 7b0755e1..d563512d 100644 --- a/src/platform/linux.rs +++ b/src/platform/linux.rs @@ -82,6 +82,26 @@ struct ProcGroupMember { state: char, } +pub(crate) fn launch_executable() -> std::io::Result { + use std::os::unix::ffi::OsStrExt; + + let executable = std::env::current_exe()?; + if !executable.is_file() { + // Linux marks the old inode as deleted after an update replaces the binary. + if let Some(path) = executable + .as_os_str() + .as_bytes() + .strip_suffix(b" (deleted)") + { + let replacement = PathBuf::from(std::ffi::OsStr::from_bytes(path)); + if replacement.is_file() { + return Ok(replacement); + } + } + } + Ok(executable) +} + pub fn raise_server_nofile_limit() {} pub(crate) fn should_draw_host_cursor_by_default() -> bool { diff --git a/src/platform/mod.rs b/src/platform/mod.rs index 67e474ff..3efad45e 100644 --- a/src/platform/mod.rs +++ b/src/platform/mod.rs @@ -55,6 +55,11 @@ pub(crate) fn classify_child_exit(_status: &portable_pty::ExitStatus) -> ChildEx ChildExitReason::Exited } +#[cfg(not(target_os = "linux"))] +pub(crate) fn launch_executable() -> std::io::Result { + std::env::current_exe() +} + pub(crate) fn detached_custom_command_process(command: &str) -> std::process::Command { let mut process = detached_custom_command_process_platform(command); configure_background_command(&mut process); -- cgit v1.2.3