Repository navigation
pty: remove CloexecPlan/close_range scan; keep FD_CLOEXEC and SPAWN_LOCK - #74
Open
chaodu-agent wants to merge 2 commits into
Open
chaodu-agent wants to merge 2 commits into
chaodu-agent wants to merge 2 commits into
Conversation
… 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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Removes the descriptor-sweep plan added by #47 and #49:
CloexecPlan,FdSet, theclose_rangeattempt, the/proc/self/fdand/dev/fdenumeration, theRLIMIT_NOFILEscan backstop,spawn_locked, and theSKIP_CLOSE_RANGE/SHEPHERD_TEST_SKIP_CLOSE_RANGEtest hooks. Two of the three fd tests are deleted (not skipped).Kept:
FD_CLOEXECon both pty fds right afteropenpty.SPAWN_LOCK.openptytakes no flags, so the lock covers the window up to CLOEXEC, and it also covers the keychain fork inprofiles.rs.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
children_inherit_only_stdio_even_when_spawned_togetherdeterministically, with extra descriptors {142, 145} on Linux and {131, 140, 143, 146} on macOS. The author reproduced it on two hosts withexec 142>/dev/null 145>/dev/nullbefore starting Shepherd. So the trigger was descriptors the launching shell/CI harness left open, not a Shepherd bug. The review listed "the leak depends on the launcher" as the first reason the PR might be unnecessary.sysconfafter fork, test isolation, ADR text,close_rangecfg). No new field leak is recorded.Because #47 recorded a real (launcher-caused) leak on two hosts, one fd test stays.
Diff
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.