From a956dba77de97cd714ab5adaabd847ed22e3d778 Mon Sep 17 00:00:00 2001 From: Nullptr Date: Mon, 23 Oct 2023 22:22:00 +0800 Subject: [PATCH] Show crash info correctly --- zygiskd/src/fuse.rs | 7 +++++-- zygiskd/src/root_impl/mod.rs | 1 - zygiskd/src/watchdog.rs | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/zygiskd/src/fuse.rs b/zygiskd/src/fuse.rs index 19a2a003..785e615a 100644 --- a/zygiskd/src/fuse.rs +++ b/zygiskd/src/fuse.rs @@ -9,7 +9,8 @@ use libc::ENOENT; use log::{debug, error, info}; use proc_maps::{get_process_maps, MapRange, Pid}; use ptrace_do::{RawProcess, TracedProcess}; -use rustix::mount::mount_bind; +use rustix::fs::UnmountFlags; +use rustix::mount::{mount_bind, unmount}; use rustix::path::Arg; use rustix::process::getpid; use crate::{constants, dl}; @@ -321,7 +322,9 @@ pub fn main() -> Result<()> { &options, )?; mount_bind(constants::PATH_FUSE_PCL, constants::PATH_PCL)?; - match session.guard.join() { + let crash = session.guard.join(); + unmount(constants::PATH_PCL, UnmountFlags::DETACH)?; + match crash { Err(e) => bail!("Fuse mount crashed: {:?}", e), _ => bail!("Fuse mount exited unexpectedly"), } diff --git a/zygiskd/src/root_impl/mod.rs b/zygiskd/src/root_impl/mod.rs index d20af6b7..8d4723bd 100644 --- a/zygiskd/src/root_impl/mod.rs +++ b/zygiskd/src/root_impl/mod.rs @@ -10,7 +10,6 @@ pub enum RootImpl { Magisk, } -// FIXME: OnceCell bugs on 32 bit static mut ROOT_IMPL: RootImpl = RootImpl::None; pub fn setup() { diff --git a/zygiskd/src/watchdog.rs b/zygiskd/src/watchdog.rs index b1dcd4cc..cbd9b230 100644 --- a/zygiskd/src/watchdog.rs +++ b/zygiskd/src/watchdog.rs @@ -18,7 +18,9 @@ static PROP_SECTIONS: LateInit<[String; 2]> = LateInit::new(); pub async fn main() -> Result<()> { let result = run().await; - set_prop_hint(constants::STATUS_CRASHED)?; + if result.is_err() { + set_prop_hint(constants::STATUS_CRASHED)?; + } result }