Skip to content

Improve Linux stdin detection for nested wrapper process trees#101

Open
jrish11 wants to merge 2 commits into
1jehuang:masterfrom
jrish11:codex/recursive-stdin-tree-detection
Open

Improve Linux stdin detection for nested wrapper process trees#101
jrish11 wants to merge 2 commits into
1jehuang:masterfrom
jrish11:codex/recursive-stdin-tree-detection

Conversation

@jrish11
Copy link
Copy Markdown

@jrish11 jrish11 commented May 2, 2026

Summary

  • make Linux stdin detection traverse full descendant process tree, not only direct children
  • keep existing stdin-pipe matching guard to avoid false positives
  • add regression test for nested wrappers ()

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

  • This is a targeted Linux reliability improvement.
  • I could not run local Rust tests in this environment because is unavailable here.

View in Codesmith
Need help on this PR? Tag @codesmith with what you need.

  • Let Codesmith autofix CI failures and bot reviews

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant