Repository navigation
WIP: executor: deliver numbered <> redirects to spawned children as O_RDWR - #2301
Merged
Merged
Conversation
Refs #2298 A numbered read-write redirect on an external command reached the spawned child as a read-only description: the numbered walk in apply_external_fd_delivery classified RedirectKind::ReadWrite with the input kinds and opened the target through the O_RDONLY input ladder, so the child held the slot but a write through it failed EBADF. GNU r_input_output opens O_RDWR|O_CREAT (make_cmd.c:682) through redir_open (redir.c:725), and do_redirections (redir.c:237) delivers that one description in the forked child. Open <> entries in the walk through the classified readwrite ladder (probe_input_redirect_readwrite) and stamp both env channels with the single dup for a self-opened entry — the child startup restore pairs equal HANDLE/WHANDLE values into one shared FileFd (init.rs); the pre_exec pin delivers the descriptor itself to foreign children. Stash-backed entries keep the read-channel stamp: the stash is an earlier entry's description, whose access mode is that entry's own. Pins: tests/issue2298_numbered_readwrite_spawn_regressions.rs — write / read / one-description-shared-offset cells through foreign sh and nested rubash observers, plus ambient and write-only controls. Expectations byte-verified against GNU bash 5.3.20.
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.
Refs #2298
What
A numbered read-write redirect (
3<>file) on an external command reached the spawned child as a read-only description: the numbered walk inapply_external_fd_deliveryclassifiedRedirectKind::ReadWritewith the input kinds and opened the target through the O_RDONLY input ladder. The child held the slot (reads worked), but a write through it failed EBADF.GNU:
r_input_outputopens O_RDWR|O_CREAT (make_cmd.c:682) throughredir_open(redir.c:725);do_redirections(redir.c:237) delivers that one description in the forked child.Change (one file:
src/executor/external_inner.rs, +36/−11)<>entries through the classified readwrite ladder (probe_input_redirect_readwrite— the same open the builtin faces use for<>), instead of the input ladder.<>entry, both env channels are stamped with the single dup: the child startup restore pairs equal HANDLE/WHANDLE values into one shared FileFd (init.rs). The pre_exec pin already delivered the descriptor itself to foreign children — it now delivers an O_RDWR one.Because the helper is shared, sequential pipeline stages gain the same delivery.
Pins
tests/issue2298_numbered_readwrite_spawn_regressions.rs(8 pins, unix-gated): write direction via foreignsh(incl. O_CREAT on a missing file) and via a nested rubash child; read direction; one-description shared-offset cells (read a line, write back at the offset — foreign and nested observers); controls for the ambient exec-bound<>face, the write-only3>spawn face, and the builtin-over-ambient face. Expectations byte-verified against GNU bash 5.3.20 with probe files on master c537d12 (write/nested/shared-offset cells red pre-fix, controls green on both).Per compile rationing:
cargo check(lib + the new test target) clean locally; the pin target itself and PR #2296's corrected issue2261 control pin are for the collector's scrubbed-fd batch.