Skip to content

Linux: contain descendants that detach faster than the process-tree poll #3

Open

Description

@chaodu-agent

On macOS, a descendant that double-forks and calls setsid before the ~250 ms process-table poll is not tracked and survives remove, exit, shutdown and drop. The documented limit is in docs/adr/native-core.md.

Linux can close the gap with PR_SET_CHILD_SUBREAPER through a per-pane supervisor that reports the program's exit status over a pipe.

Needs a Linux build and tests (the current build host is macOS).

Acceptance: a test that detaches immediately leaves no survivors on Linux.

Activity

  1. chaodu-agent commented on Nov 13, 2026

    @chaodu-agent
    CollaboratorAuthor

    Facts from the Linux verification of PR #11 (#11) at 3590923, run on p1 (Ubuntu x86_64, Rust 1.99.1):

    • PR WIP: environment-marker sweep for detached descendants (not for merge yet) #11's test target does not compile on Linux: src/native/tests.rs:1285 uses Command without use std::process::Command; (E0433). cargo test exits 101 with 0 tests run, so the 4 detach tests did not run and this issue's acceptance test is not demonstrated on Linux.
    • The marker-sweep design (OPENAB_SHEPHERD_PANE found via /proc/<pid>/environ) escapes: env-scrubbing execs (env -i, sudo, su -, login, systemd-run, ssh, and container launchers such as docker run); a process that overwrites its env region; non-dumpable or other-uid (setuid) processes, where the environ read fails silently.
    • A subreaper would close these cases; the sweep does not.
    • docs/adr/native-core.md (L357-361) should say the sweep is a mitigation, not a fix. This issue should stay open unless that is accepted.
  2. chaodu-agent commented on Nov 17, 2026

    @chaodu-agent
    CollaboratorAuthor

    Status after PR #11 was closed: the marker-sweep approach is not going ahead (see the closing comment there). This stays open at low priority. The smallest candidate is Linux-only: make the pane's leader a child subreaper in pre_exec so detached descendants are reparented to it and the existing parent walk finds them (about 20 lines, to be checked on a Linux host first). Not planned until a field report shows a pane leaving a process behind that matters; under the one-user, one-account model it is not a security issue.

  3. added
    p3
    and removed on Nov 17, 2026
  4. chaodu-agent commented on Nov 17, 2026

    @chaodu-agent
    CollaboratorAuthor

    Refs #3. PR #134 scans the process table once per tick instead of once per pane. Idle holder with 8 panes on a Linux x86_64 host: 14.92 to 1.86 percent CPU (300 s). The target of well under 1 percent is not met; the remainder is the floor of one scan per 250 ms tick. The quiet back-off (recommendation 3) and /proc children (recommendation 4) stay as follow-ups. Front restart time is unchanged.

  5. chaodu-agent commented on Nov 19, 2026

    @chaodu-agent
    CollaboratorAuthor

    Result of the scan-once-per-tick change, merged in #134 (merge commit 1f1f902, head 84ffce4).

    • Idle holder CPU on p1 (8 idle panes): 14.92 % before, 1.86 % after. The target of below 1 % was not met.
    • Remaining cost: about 4 process-table scans per second, about 4.5 ms each.
    • Restart time is unchanged within noise (0.55 to 0.74 s before and after).
    • Measurements are in .agents/tasks/perf/procs-scan/ (git-ignored).

    Further reduction needs the quiet back-off, which was out of scope for #134. Not started.

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

    p3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions