fix: enumerate foreground process groups without CONFIG_PROC_CHILDREN - #2269
fix: enumerate foreground process groups without CONFIG_PROC_CHILDREN#2269knowsuchagency wants to merge 2 commits into
Conversation
Kernels built without CONFIG_PROC_CHILDREN (some container hosts) expose no /proc/<pid>/task/<tid>/children files, so the foreground job walk only ever returned its own roots and wrapper-launched agents (mise run -> claude) were never identified or shown in the agents sidebar. Probe the interface once at startup and fall back to scanning /proc, reusing the existing process-group membership filter; child-group inference gets the same fallback via a ppid scan. Claude-Session: https://claude.ai/code/session_013DSUQrZfBkKtumyVZQxeT3
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughLinux process-group discovery now detects ChangesLinux process-group discovery
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Caller
participant Discovery as Linux process-group discovery
participant ProcChildren as /proc child files
participant ProcScan as all_process_pids
participant GroupLookup as process-group lookup
Caller->>Discovery: enumerate child groups or foreground members
Discovery->>ProcChildren: read task-derived children
alt child files unsupported
Discovery->>ProcScan: enumerate visible /proc PIDs
ProcScan-->>Discovery: fallback candidate PIDs
end
Discovery->>GroupLookup: filter candidates by process group
GroupLookup-->>Discovery: matching process groups or members
Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Greptile SummaryThe PR restores Linux foreground-agent detection on kernels without
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| src/platform/linux.rs | Adds guarded /proc scanning fallbacks for foreground process-group discovery while retaining existing membership filtering and scan limits. |
Reviews (2): Last reviewed commit: "fix(linux): bound the child-group /proc ..." | Re-trigger Greptile
The fallback ppid scan read every visible pid before CHILD_GROUPS_SCAN_LIMIT could apply, so an unexpectedly wide parent did unbounded work on the way to failing closed. Stream /proc instead of materializing every pid and stop one past the limit, which is all the caller needs to return None. Claude-Session: https://claude.ai/code/session_013DSUQrZfBkKtumyVZQxeT3
Current behavior
On Linux kernels built without
CONFIG_PROC_CHILDREN, an agent started through a wrapper is never identified. Runningclaudedirectly works, because the shell puts it in the foreground process group and it is the group leader. Running it through a task runner (mise run <task>->claude) does not: the pane showsagent_status: "unknown", never appears in the agents sidebar orherdr agent list, andherdr pane process-infolists only the wrapper.CONFIG_PROC_CHILDRENis optional and off in some container/Kubernetes node kernels, so this is not exotic hardware; on those hosts every wrapper-launched agent is invisible.Cause
foreground_process_group_memberswalks/proc/<pid>/task/<tid>/childrento find the pane's process subtree. Those files only exist when the kernel was built withCONFIG_PROC_CHILDREN. When they are missing, every read comes back empty, soprocess_tree_pidsreturns only the roots it was seeded with and the real agent process is never inspected.child_groups_foreground_process_groupreads the same files and has the same blind spot.Fix
Probe the interface once (cached in a
OnceLock) by stat'ing our own/proc/<pid>/task/<pid>/children, and only when it is absent fall back to enumerating/proc. The existinglive_process_group_memberfilter is unchanged and still decides membership, so the fallback widens the candidate set without loosening what counts as a member.child_groups_foreground_process_groupgets the equivalent fallback via a ppid scan.On kernels that do expose the children files — the overwhelming majority — nothing changes: the probe short-circuits and
/procis never enumerated. I deliberately kept the scan behind the probe rather than making it unconditional, since the pane-scoped walk exists precisely to avoid full/procsweeps (#1390), and the fallback is additionally gated by the existingshould_probe_foreground_jobthrottle rather than running every poll.Verification
Reproduced live in two containers on kernel 6.18.35 (no
CONFIG_PROC_CHILDREN). Before: withmise run normlaunchingclaudein a pane,herdr pane process-inforeported onlymise run normwhilepsshowedclaudein the same pgid, and the pane never appeared inherdr agent list. After: both processes are enumerated and the pane is detected and listed.just cipasses on this branch apart fromworkspace::git::status::tests::git_status_recomputes_ahead_behind_when_head_moves, which fails identically on a cleanorigin/mastercheckout here and is unrelated to this change. All 42platform::tests pass.Tests
New unit tests cover both directions of the probe for each function (fallback used when children files are absent, scan not called when they are present), the empty-group case, and
/proc/<pid>/statppid parsing including acommcontaining). The support probe itself is only asserted to be stable across calls, since its answer depends on the host kernel; the behavior it gates is covered by the injected-flag tests.No docs change needed — this restores intended behavior on affected kernels rather than changing any documented behavior.
https://claude.ai/code/session_013DSUQrZfBkKtumyVZQxeT3