Skip to content

pty: remove CloexecPlan/close_range scan; keep FD_CLOEXEC and SPAWN_LOCK - #74

Open
chaodu-agent wants to merge 2 commits into
mainfrom
simplify/d5-fd-plan
Open

chaodu-agent wants to merge 2 commits into
mainfrom
simplify/d5-fd-plan

Conversation

@chaodu-agent

Copy link
Copy Markdown
Collaborator

Summary

Removes the descriptor-sweep plan added by #47 and #49: CloexecPlan, FdSet, the close_range attempt, the /proc/self/fd and /dev/fd enumeration, the RLIMIT_NOFILE scan backstop, spawn_locked, and the SKIP_CLOSE_RANGE / SHEPHERD_TEST_SKIP_CLOSE_RANGE test hooks. Two of the three fd tests are deleted (not skipped).

Kept:

  • FD_CLOEXEC on both pty fds right after openpty.
  • SPAWN_LOCK. openpty takes no flags, so the lock covers the window up to CLOEXEC, and it also covers the keychain fork in profiles.rs.
  • One test (children_inherit_only_stdio_even_when_spawned_together) that a spawned child sees only fds 0-2 plus the lister's own.

No behaviour change for remote bots, operators or shared panes. Docs (docs/operations.md, ADR native-core spawn procedure) no longer describe the sweep and now say that a clean launcher descriptor table is the launcher's job. The tool schema snapshot is untouched.

Evidence recorded in the #47 / #49 threads

Because #47 recorded a real (launcher-caused) leak on two hosts, one fd test stays.

Diff

 4 files changed, 6 insertions(+), 342 deletions(-)

Test record (head 0005167)

macmini (macOS) and p1 (Linux): cargo fmt --check, cargo clippy --all-targets -- -D warnings, cargo test: 481 passed, 0 failed on both.

… pty

Keep FD_CLOEXEC on both pty fds after openpty, SPAWN_LOCK (openpty takes
no flags; the lock covers the window to CLOEXEC and the keychain fork) and
the one test that a pane child sees only stdio. Drop the two other fd tests
and the SHEPHERD_TEST_SKIP_CLOSE_RANGE hooks. Docs updated.

Ran on macmini (macOS) and p1 (Linux): cargo fmt --check, clippy --all-targets
-D warnings, cargo test: 481 passed, 0 failed on both.
CI runners hand the test process descriptors it did not open; without
the close_range scan a child inherits them, which is not a Shepherd leak.
The test now subtracts the descriptors the process held without
close-on-exec at start.

Ran on macmini (macOS) and p1 (Linux), with extra inherited fds 9, 142, 145:
cargo fmt --check, cargo clippy --all-targets -- -D warnings, cargo test:
all pass (481 unit tests).
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