From 26db26e416318e17a6e7f3f196ec72109fb37998 Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Tue, 30 Jun 2026 19:48:56 +0300 Subject: fix: keep remote sessions alive across disconnects --- src/platform/mod.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/platform/mod.rs') diff --git a/src/platform/mod.rs b/src/platform/mod.rs index 0b5f9ecb..169b7c1c 100644 --- a/src/platform/mod.rs +++ b/src/platform/mod.rs @@ -40,6 +40,25 @@ pub(crate) const fn capabilities() -> PlatformCapabilities { } } +#[cfg(any(target_os = "linux", target_os = "macos"))] +pub fn detach_server_daemon_command(command: &mut std::process::Command) { + use std::os::unix::process::CommandExt; + + unsafe { + command.pre_exec(|| { + if libc::setsid() < 0 { + return Err(std::io::Error::last_os_error()); + } + Ok(()) + }); + } +} + +#[cfg(any(target_os = "linux", target_os = "macos"))] +pub fn current_process_is_detached_server_daemon() -> bool { + unsafe { libc::getsid(0) == libc::getpid() } +} + #[cfg(unix)] #[derive(Debug, Clone, PartialEq, Eq)] pub struct ClipboardCommand { -- cgit v1.2.3