Add daemon process watchdog with crash rate-limiting#770
Open
yunsmall wants to merge 1 commit into
Open
Conversation
When the daemon crashes, all existing app connections are permanently lost (Binder death triggers service reference clears and manager suicide). However persistent state lives on disk and new processes can still get a fresh binder — so restarting the daemon still recovers meaningful functionality. - service.sh: wrap the unshare launch in a rate-limited watchdog loop. If the daemon crashes more than 3 times within 60 seconds, the watchdog enters a 3-minute cooldown before retrying and resets the counter. Normal restarts use a 5-second delay. The loop runs in background (&) so Magisk late_start is never blocked. - daemon: drop 'exec' so that when app_process exits, control returns to the daemon script, which finishes, allowing the watchdog in service.sh to iterate.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the Vector daemon process crashes, all existing Binder connections
are permanently severed:
System.exit(0)in itsDeathRecipient.VectorServiceClientservicereference and never attempt to reconnect.
postAppSpecializeand skip Xposed injection entirely.
system_servercan recover, becauseVectorDaemonre-injectsinto it on startup.
However, all persistent state (module configs, scopes, preferences, logs)
lives on disk and survives the crash. If the daemon is restarted, new
processes can once again get a fresh binder and be injected — so an
automatic restart still restores meaningful functionality.
Changes
zygisk/module/service.shWrap the
unsharelaunch in a rate-limited watchdog loop:watchdog enters a 3-minute cooldown before retrying, then resets
the counter. This prevents tight crash-loops from burning CPU.
done &), so Magisk'slate_startservice handler returns immediately and is never blocked.unshare -m, creating a fresh mount namespace;stale mounts from a previous crashed daemon do not accumulate.
zygisk/module/daemonDrop the
execkeyword from theapp_processinvocation. Withoutexec, theapp_processprocess runs as a child of the daemon script.When it exits, control returns to the shell script, which finishes,
allowing the watchdog loop in
service.shto iterate. (Previouslyexecreplaced the shell process, so when the daemon died there wasnothing left to restart it.)
Compatibility
No effect on the daemon's normal operation path. When the daemon does
not crash, the watchdog loop is parked at
unsharewaiting for it toexit — identical to the original behavior.