aboutsummaryrefslogtreecommitdiff
path: root/src/platform
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
parentc71c6c108245b91f6478d95a3abf9a9a9e2e57a9 (diff)
fix: keep remote sessions alive across disconnects
Diffstat (limited to 'src/platform')
-rw-r--r--src/platform/fallback.rs9
-rw-r--r--src/platform/mod.rs19
-rw-r--r--src/platform/windows.rs6
3 files changed, 34 insertions, 0 deletions
diff --git a/src/platform/fallback.rs b/src/platform/fallback.rs
index b27f181e..25bc761c 100644
--- a/src/platform/fallback.rs
+++ b/src/platform/fallback.rs
@@ -1,4 +1,5 @@
use std::path::PathBuf;
+use std::process::Command;
use super::{ClipboardImage, ForegroundJob, Signal};
@@ -6,6 +7,14 @@ use super::{ClipboardImage, ForegroundJob, Signal};
pub fn raise_server_nofile_limit() {}
/// Unsupported platform stub.
+pub fn detach_server_daemon_command(_command: &mut Command) {}
+
+/// Unsupported platform stub.
+pub fn current_process_is_detached_server_daemon() -> bool {
+ false
+}
+
+/// Unsupported platform stub.
pub fn foreground_job(_child_pid: u32) -> Option<ForegroundJob> {
None
}
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 {
diff --git a/src/platform/windows.rs b/src/platform/windows.rs
index 12a8345f..e7a77e35 100644
--- a/src/platform/windows.rs
+++ b/src/platform/windows.rs
@@ -46,6 +46,12 @@ struct WindowsProcessEntry {
pub fn raise_server_nofile_limit() {}
+pub fn detach_server_daemon_command(_command: &mut std::process::Command) {}
+
+pub fn current_process_is_detached_server_daemon() -> bool {
+ false
+}
+
pub fn foreground_job(child_pid: u32) -> Option<ForegroundJob> {
let entries = snapshot_processes();
select_pane_foreground_job(child_pid, &entries)