Skip to content

Improve Linux stdin detection for nested wrapper process trees - #101

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

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

Conversation

@jrish11

@jrish11 jrish11 commented May 2, 2026 •

Copy link
Copy Markdown

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 1jehuang#86
@1jehuang 1jehuang added the triage: converted PR triage: worth tracking as an issue label Jun 12, 2026
@1jehuang

Copy link
Copy Markdown
Owner

Thanks! This repo no longer accepts external PRs, but the underlying problem is real - it's now tracked in #373 (with credit to this PR). Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

triage: converted PR triage: worth tracking as an issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants