Repository navigation
Start a child Run from the running binary, not its install path - #265
Merged
Merged
Conversation
On Linux a child Run (a Ticket's Run in a Spec run, a Base fix) is now started through /proc/self/exe, so a Spec run or a Run whose installed binary was replaced or removed after it started can still start its children, and they run its own version. The child keeps the parent's name for ps, pgrep and top, and a child that can't be started names the executable that was tried. Closes #261 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, share the test helpers A child Run that can't be started names the file its link leads to as well as the link. The child's argv[0] is only set on Linux, where the child is started through a link. The harness copies the binary with cp, so the copy is never open for writing in the test process. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
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
A child Run (a Ticket's Run in a Spec run, a Base fix) is started from the binary the parent is running, not from the path that binary was installed at.
name_this_processis not in the brief. A process started through/proc/self/exeis namedexeby the kernel, so without itpgrep thirdshift,pkill thirdshiftandtopwould stop seeing every child Run on Linux. It runs first thing in every thirdshift process and is a no-op off Linux.The README's Updating section and the update module's doc comment now say the old binary also serves the child Runs started later on Linux, and that on macOS a child Run started after an update runs the new binary.
Seams tested: the compiled
thirdshiftbinary through the tests'Scenarioharness, and the child Run module's start error (start_from, private to the module).Evidence
Before: the three new end-to-end tests, run against the old
start():and, with
/proc/self/exebut noname_this_process, the name of CI watching, CI-fix Repair and the Repair cap #22's Run:left: "exe\n" right: "thirdshift\n".After:
cargo fmt --checkandcargo clippy --all-targets -- -D warningsclean;cargo test: 28 suites, 577 tests passed, 0 failed.The second Spec run test has #22, started after the replacement, meet an Inherited failure and start its Base fix: a child started through the link starting a child of its own. All three are Linux-only.
Not run here: the macOS build and tests. No macOS target is installed on this machine; CI's
test-macosjob covers it.One flake seen and fixed along the way: one of the new tests failed once in a full-suite run at the harness's
spawn()of the copied binary. I did not capture the error; the likely cause is "Text file busy" from the copy being open for writing in the test process while another test forked. The harness now copies withcp, andspec_runandbase_fixthen passed three times in a row plus the full suite.Unaddressed findings
Standards
name_this_processwidens the child Run module's interface with an ordering constraint (mainmust call it first, in every process). Kept: the name can only be set from inside the child, and the reason for it lives in the child Run module.cfg!inown_executableandstart_from,#[cfg]inname_this_process).libc::prctldoesn't exist on macOS, so that one must be compiled out; the others read better as plainifs. The repeatedargs_os().next()was addressed withown_command().Spec
name_this_processandarg0go beyond "what it passes toCommand::newis what changes". Kept, for the reason in the Summary;arg0is now Linux-only, so macOS'sargv[0]is as it was.from /proc/self/exe (…)) is asserted by no test. A spawn through/proc/self/execan't be made to fail on demand; the unit tests cover the same code with a missing path and with a dangling link.Merge Danger
Door: two-way
Reverting the commit restores the old spawn; nothing is persisted or migrated.
Blast Radius: child-Runs
Every Ticket's Run and Base fix on Linux now starts through
/proc/self/exe, so a host with no/procmounted could not start one (current_exe()reads the same link on Linux, so it failed there before too). Every thirdshift process on Linux now sets its own process name fromargv[0], which changes whatpgrep/topshow only if it was started under anargv[0]that differs from its file name.Closes #261
🤖 Generated with Claude Code