Repository navigation
WIP: fix(executor): keep the spawn capture record across a route decline (niubash#729) - #2264
Merged
Merged
Conversation
…niubash#729) try_external_route spent the spawn plan's capture outcome record unconditionally after a route consult — including on Declined. When the plan bound fd 1 to the active capture (the realization a `command <external>` builtin pipeline stage produces: its re-dispatch runs in-process under the stage capture), the record owns the capture pipe's reader and keys the prepared spawn's capture drain, so a declining provider silently disarmed the spawn: the child wrote into a pipe nobody routed into the capture and the stage produced no output (`command perl ... | wc -c` printed 0 in niubash, which registers its FFI provider unconditionally and declines while its switch is off; the provider-less rubash binary exits the consult at the no-provider gate and was never affected). Spend the record only on the Handled outcomes, where the route consumed the call and no spawn follows. On a decline the prepared spawn owns it: spawn_external_process consumes it on every success path and drops it on the spawn-error path, so nothing leaks into the next command. This restores the fn's documented contract: a decline leaves every piece of spawn state exactly as the preparation left it. GNU: execute_cmd.c:2620 (execute_in_subshell hands each pipeline element the pipe fds) and execute_cmd.c:6373 (do_piping) — every element's fd 1 is the pipeline; a `command` prefix changes nothing about the wiring. Regression pin: issue729_declining_provider_keeps_command_stage_output (new DeclineRecorded mock behavior; first / middle / `command -p` stages asserted byte-identical to the no-provider baseline). The Decline x active-capture cell was previously untested: the decline battery used file redirects only, and the capture battery a claiming provider. Refs unixwin/niubash#729
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.
WIP — collector: batch-run the
executor::external_routelib tests and the probes before merge (author rancargo check+cargo check --testsonly, per the rationing regime).What
Refs unixwin/niubash#729 —
command perl -e 'print "X\n"' | wc -cprints 0 in niubash (works in the rubash binary and in GNU): a non-finalcommand <external>pipeline stage loses its stdout.Attribution: engine (rubash), route seam — not the niu host
niubash registers its FFI route provider unconditionally (declining every call while its switch is off); the rubash binary registers none. The stage re-dispatch (
command→execute_external_inner) prepares a capture-bound spawn plan whose fd 1 is the stage capture, then consults the route. On Declined,try_external_routeunconditionally spentexternal_stdio_outcome— the record that owns the capture pipe's reader and keys the prepared spawn's capture drain. The spawn that followed wrote into a pipe nobody routed into the capture, so the stage produced nothing. With no provider registered, the consult exits at its first gate before touching the record — hence niu-only. The spend also contradicts the fn's documented contract ("a decline leaves every piece of spawn state exactly as the preparation left it"). Defect verified present at the issue's engine rev c31b357 and at master.Adjacent but different from #2255 (a stage's own redirects not applied): this is capture routing after redirect application, in the route seam.
Fix
Spend the record only on the Handled outcomes (Completed/Cancelled — no spawn follows). On Declined, the prepared spawn owns it:
spawn_external_processconsumes it on every success path and drops it on the spawn-error path, so nothing leaks into the next command.GNU anchor: execute_cmd.c:2620 / :6373 — every pipeline element's fd 1 is the pipeline; a
commandprefix changes nothing about the wiring.Pins
issue729_declining_provider_keeps_command_stage_outputin the existing route harness, with a newDeclineRecordedmock behavior (records the consult, then declines — non-vacuity):command ddas first stage, middle stage, andcommand -p dd, each byte-identical to the no-provider baseline. The Decline × active-capture cell was previously untested (decline battery = file redirects only; capture battery = claiming provider).Full evidence chain: workdir REPORT.md (fix-729-command-pipeline) — niu picks this up on its next rubash pin bump; no niu code change.