aboutsummaryrefslogtreecommitdiff
path: root/src/platform/mod.rs
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-06-30 19:48:56 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-06-30 19:49:55 +0300
commit26db26e416318e17a6e7f3f196ec72109fb37998 (patch)
tree93b18888e9f4bc66d27ef1af5a4e7aad6db77339 /src/platform/mod.rs
parentc71c6c108245b91f6478d95a3abf9a9a9e2e57a9 (diff)
fix: keep remote sessions alive across disconnects
Diffstat (limited to 'src/platform/mod.rs')
-rw-r--r--src/platform/mod.rs19
1 files changed, 19 insertions, 0 deletions
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 {