fix: suspend only when there is a parent process (#3008)

This commit is contained in:
三咲雅 misaki masa 2025-07-21 14:42:10 +08:00 committed by GitHub
parent 74bd98031e
commit bfe12c8052
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 15 additions and 10 deletions

10
Cargo.lock generated
View file

@ -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]]

View file

@ -14,8 +14,10 @@ impl Actor for Suspend {
fn act(_: &mut Ctx, _: Self::Options) -> Result<Data> {
#[cfg(unix)]
unsafe {
libc::raise(libc::SIGTSTP);
if !yazi_shared::session_leader() {
unsafe {
libc::raise(libc::SIGTSTP);
}
}
succ!();
}

View file

@ -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)?;

View file

@ -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!($layer:$name) as yazi_actor::Actor>::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!($layer:$name) as yazi_actor::Actor>::act($cx, $opt),
Some(e @ Err(_)) => e,
};
$cx.level -= 1;

View file

@ -25,3 +25,6 @@ fn hostname_impl() -> Result<String, std::io::Error> {
.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() } }