From bfe12c805277bdb4614143c22f3daea31ab90a1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E9=9B=85=20misaki=20masa?= Date: Mon, 21 Jul 2025 14:42:10 +0800 Subject: [PATCH] fix: suspend only when there is a parent process (#3008) --- Cargo.lock | 10 +++++----- yazi-actor/src/mgr/suspend.rs | 6 ++++-- yazi-boot/src/actions/debug.rs | 2 +- yazi-macro/src/actor.rs | 4 ++-- yazi-shared/src/os.rs | 3 +++ 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 257acce1..5e0d52c9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2026,9 +2026,9 @@ dependencies = [ [[package]] name = "rand" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fbfd9d094a40bf3ae768db9361049ace4c0e04a4fd6b359518bd7b73a73dd97" +checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" dependencies = [ "rand_chacha 0.9.0", "rand_core 0.9.3", @@ -2155,9 +2155,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.13" +version = "0.5.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d04b7d0ee6b4a0207a0a7adb104d23ecb0b47d6beae7152d0fa34b692b29fd6" +checksum = "de3a5d9f0aba1dbcec1cc47f0ff94a4b778fe55bca98a6dfa92e4e094e57b1c4" dependencies = [ "bitflags 2.9.1", ] @@ -2907,7 +2907,7 @@ version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b907da542cbced5261bd3256de1b3a1bf340a3d37f93425a07362a1d687de56" dependencies = [ - "rand 0.9.1", + "rand 0.9.2", ] [[package]] diff --git a/yazi-actor/src/mgr/suspend.rs b/yazi-actor/src/mgr/suspend.rs index c8b881f3..61da21fb 100644 --- a/yazi-actor/src/mgr/suspend.rs +++ b/yazi-actor/src/mgr/suspend.rs @@ -14,8 +14,10 @@ impl Actor for Suspend { fn act(_: &mut Ctx, _: Self::Options) -> Result { #[cfg(unix)] - unsafe { - libc::raise(libc::SIGTSTP); + if !yazi_shared::session_leader() { + unsafe { + libc::raise(libc::SIGTSTP); + } } succ!(); } diff --git a/yazi-boot/src/actions/debug.rs b/yazi-boot/src/actions/debug.rs index 07ae04dd..9ee15264 100644 --- a/yazi-boot/src/actions/debug.rs +++ b/yazi-boot/src/actions/debug.rs @@ -39,7 +39,7 @@ impl Actions { writeln!(s, " WAYFIRE_SOCKET : {:?}", env::var_os("WAYFIRE_SOCKET"))?; writeln!(s, "\nSSH")?; - writeln!(s, " shared.in_ssh_connection: {:?}", yazi_shared::in_ssh_connection())?; + writeln!(s, " shared.in_ssh_connection: {}", yazi_shared::in_ssh_connection())?; writeln!(s, "\nWSL")?; writeln!(s, " WSL: {:?}", yazi_adapter::WSL)?; diff --git a/yazi-macro/src/actor.rs b/yazi-macro/src/actor.rs index f73b1199..df72cf68 100644 --- a/yazi-macro/src/actor.rs +++ b/yazi-macro/src/actor.rs @@ -8,8 +8,8 @@ macro_rules! act { (@impl $layer:ident : $name:ident, $cx:ident, $opt:ident) => {{ $cx.level += 1; let result = match act!(@pre $layer:$name, $cx, $opt) { - None | Some(Ok(yazi_shared::event::Data::Boolean(false))) => ::act($cx, $opt), - Some(Ok(_)) => Err(anyhow::anyhow!("canceled on preflight")), + Some(Ok(yazi_shared::event::Data::Boolean(true))) => Err(anyhow::anyhow!("canceled on preflight")), + None | Some(Ok(_)) => ::act($cx, $opt), Some(e @ Err(_)) => e, }; $cx.level -= 1; diff --git a/yazi-shared/src/os.rs b/yazi-shared/src/os.rs index fa9f213a..3eaf57ea 100644 --- a/yazi-shared/src/os.rs +++ b/yazi-shared/src/os.rs @@ -25,3 +25,6 @@ fn hostname_impl() -> Result { .map_err(|_| std::io::Error::other("invalid hostname")) .map(|s| s.to_owned()) } + +#[cfg(unix)] +pub fn session_leader() -> bool { unsafe { libc::getsid(0) == libc::getpid() } }