Skip to content

Detect stdin readers through nested Linux child process trees #373

Closed

Description

@1jehuang

Linux stdin-reader detection does not traverse nested wrapper process chains (no recursive child-by-parent walk), so wrapped processes can evade detection.

Credit: originally proposed in PR #101. This repo no longer accepts external PRs, so the problem is tracked here instead.

Activity

  1. added
    from-pr
    on Jun 12, 2026
  2. added
    triage: reproducible
    autonomous: likely
    priority: low
    on Jun 25, 2026
  3. 1jehuang commented on Jun 25, 2026

    @1jehuang
    OwnerAuthor

    Triage: reproducible, clear fix path.

    Confirmed in crates/jcode-core/src/stdin_detect.rs. The Linux check_process_tree (lines 83-118) only walks direct children via direct_children(pid) (/proc/<pid>/task/<tid>/children, lines 129-156) and checks each once with check_inner(child_pid, true). There is no recursion into grandchildren, so a wrapper chain (e.g. sh -> wrapper -> reader) where an intermediate process is not itself reading stdin will not be detected.

    Fix path: make the traversal recursive (BFS/DFS over direct_children), keeping the existing same-stdin-pipe gate (parent_stdin_link comparison at lines 104-110) at each hop and a visited-set / depth cap to bound cost and avoid cycles. The fallback children_via_proc_scan already returns the full PPid-based child set per node, so recursion composes naturally.

    Labels: autonomous: likely (mechanical change, but needs care on the per-hop pipe-sharing check and CPU cost of deeper polling), priority: low (edge case; basic + direct-child detection already works).

  4. 1jehuang commented on Jun 25, 2026

    @1jehuang
    OwnerAuthor

    Fixed in b96dfa47 (pending release). Built and tests pass on Linux. See commit message for the specific change for this issue.

  5. added
    triage: fixed-pending-release
    and removed
    triage: reproducible
    on Jun 25, 2026
  6. 1jehuang commented on Jun 28, 2026

    @1jehuang
    OwnerAuthor

    Released in v0.32.0. Run jcode update to get it.

  7. removed
    triage: fixed-pending-release
    on Jun 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    autonomous: likelyfrom-prpriority: low

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions