fix(root): enforce command deadlines while draining output - #6234
Closed
wangtong10086 wants to merge 1 commit into
Closed
wangtong10086 wants to merge 1 commit into
wangtong10086 wants to merge 1 commit into
Conversation
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.
Root commands can block before reaching their timeout because stdout is read to EOF before
waitFor. A detached child that retains stdout can also keep an otherwise completedsucommand waiting.Add a bounded process runner that drains available output while checking a monotonic deadline, caps retained output, preserves nonzero exit status, and closes streams on exit. Root scripts also run inside Android's
timeoutso the root shell has its own deadline. Root availability checks use the same runner. Command strings are omitted from failure logs, and generated scripts use owner-only read/write permissions.Validation on this branch:
:app:testPlaystoreDebugUnitTest --tests com.v2ray.ang.root.RootProcessRunnerTest:app:testPlaystoreDebugUnitTest— 85 tests passed.:app:compilePlaystoreDebugKotlintimeouttest prevented a child from writing a delayed marker after termination.Not run: runtime checks on Android 7–15 and non-arm64 devices; those devices were unavailable. The runner avoids
Process.waitFor(timeout, unit)to retain API 24–25 compatibility. The device probe validates command execution; it does not establish lifecycle correctness for the upstream root service as a whole.