fix(stdin-detect): walk full descendant tree, not just direct children (#86)#192
Open
quangdang46 wants to merge 1 commit into
Open
fix(stdin-detect): walk full descendant tree, not just direct children (#86)#192quangdang46 wants to merge 1 commit into
quangdang46 wants to merge 1 commit into
Conversation
`check_process_tree` previously scanned /proc once and stopped at direct children. Wrappers like bash -c "cat" worked, but nested chains like bash -> sh -> cat (or any tool that re-execs through an extra shell layer) silently reported NotReading because the grandchild was never inspected. Build a parent->children graph from /proc up front, then DFS through all descendants (cycle-safe via a visited set). Each step still verifies the descendant shares the parent's stdin link before falling into strict check_inner, so we don't accidentally flag unrelated descendants reading their own stdin. Test `test_grandchild_process_tree_detection` covers the bash -> sh -> cat case. Ports upstream PR 1jehuang#101. The JCODE_CHEAP_MODE config tweak the same upstream PR also bundles is unrelated to stdin detection and is intentionally NOT applied here — it can be ported separately if desired. Closes #86
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.
What
check_process_treepreviously scanned/proconce and stopped at direct children. Wrappers likebash -c "cat"worked, but nested chains (bash -> sh -> cator any tool that re-execs through an extra shell layer) silently reportedNotReadingbecause the grandchild was never inspected.This addresses issue #86: #86
Changes
parent -> childrengraph from/procup front.visitedset).check_inner— same correctness guard as the old direct-children path.test_grandchild_process_tree_detectioncoveringbash -> sh -> cat.Tests
Notes / scope deviation from upstream
Upstream PR 1jehuang#101 also bundles a
JCODE_CHEAP_MODEconfig tweak (forces low-cost defaults). That is unrelated to stdin detection and is intentionally NOT applied here — port it separately if desired.