Improve Linux stdin detection for nested wrapper process trees#101
Open
jrish11 wants to merge 2 commits into
Open
Improve Linux stdin detection for nested wrapper process trees#101jrish11 wants to merge 2 commits into
jrish11 wants to merge 2 commits into
Conversation
zombi3butt
pushed a commit
to zombi3butt/jcode
that referenced
this pull request
May 22, 2026
`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 quangdang46#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.
Summary
Why
Wrapper chains are common in agent/tool launch flows. The previous direct-child-only scan could miss the actual stdin reader when it lived at grandchild depth.
Notes
Need help on this PR? Tag
@codesmithwith what you need.