Repository navigation
Conversation
… in a deleted cwd In a deleted cwd the probe faces classified FIFO targets by joined-path metadata, which a dead cwd defeats, so a relative output redirect to an existing FIFO failed instantly with ENOENT. GNU blocks on the rendezvous and succeeds. Remove the FIFO gates from the create/append faces and open once via the cwd anchor; probes classify by fstatat instead. Refs unixwin#3286 Regression pin: tests/issue3286_deleted_cwd_fifo_redirect.rs (7 tests; fail-first the > , >> , no-reader and exec faces failed on the unpatched tree, 7/7 pass after). Adjacent families (issue1820, issue3268, issue2550) green. GNU 5.3.20 oracle agrees on all probed shapes. Owed: exec <> FIFO read-write face still ENOENT; cd redirects fail for all relative targets in a deleted cwd; write_to_fd empty-stream pairing residual; unixwin#1967 net counting test is a pre-existing harness flake.
This was referenced Nov 15, 2026
Merged
Merged
Merged
Member
|
Superseded by #3867 (fix/3363-absorb-deleted-cwd-fifo). |
caomengxuan666
added a commit
that referenced
this pull request
Nov 18, 2026
…deleted cwd (Refs #3286) (#3867) * fix(executor): open exec-face FIFO redirects via the cwd anchor in a deleted cwd (Refs #3286) Absorbs the two trap_exec.rs residuals of PR #3363 after #3735 landed the command-attached faces: bare `exec > fifo` / `exec >> fifo` (persistent bind) and `exec <cmd> >> fifo` (replacement spawn) still died ENOENT from a deleted cwd. Root cause: the redirect machine's probe/bind split classifies an existing FIFO by anchor fstatat/faccessat and keeps no File for it, so the bind performs the one real open — but the two exec-face binds opened by dead joined string path instead of the cwd anchor: `set_fd_output_file` did a plain `FileFd::open_write`, and `exec_spawn_open_output`'s append arm did a raw `open_redirect_append`, bypassing the registry (rubash#1964) and the anchor. GNU anchors (audit tree `build-gnu/bash-5.3/redir.c`): :237 `do_redirections` (one `do_redirection_internal` per entry), :790 `do_redirection_internal`, :725 `redir_open` (the single open per redirect entry). (`redir.c:348` is inside `heredoc_expand`'s doc comment, not the dispatcher.) Changes (`src/executor/trap_exec.rs` only): - `set_fd_output_file`: for a relative operand, try `open_via_cwd_anchor` with O_WRONLY|O_CREAT|(O_TRUNC|O_APPEND) first; fall back to the plain open when the anchor does not apply (live cwd / non-unix). For an existing FIFO this is the rendezvous open. - `exec_spawn_open_output`: the append arm now calls `open_append_target_for(Some(redirect), target)` — the redirect-aware classified open whose Filesystem arm opens via the anchor — instead of the raw `open_redirect_append`. Regression pins (`tests/issue3286_deleted_cwd_fifo_redirect.rs`, unix only, 3 tests): bare `exec > ../fifo`, bare `exec >> ../fifo`, and `exec echo hello >> ../fifo` from a deleted cwd, each with a background reader; the command-attached faces and the missing-target control already live in `tests/issue3286_deleted_cwd_fifo_redirect_regressions.rs` (#3735) and are not duplicated here. ## 本 PR 删除了什么 - 无文件删除,无公开面删除,无行为删除。 - 唯一移除的调用点是 `exec_spawn_open_output` 追加臂里的 `open_redirect_append(&self.session_path(...))` 原始打开, 由等价的分类打开 `open_append_target_for` 替代(同一 O_WRONLY|O_CREAT|O_APPEND 语义,另加分类与锚路由)。 - PR #3363 的钉 1–4、7 未随附:已由 #3735 的 `issue3286_deleted_cwd_fifo_redirect_regressions.rs` 覆盖, 不重复。 UNVERIFIED-BY-CAPTAIN * fix(executor): stamp exec-spawn cwd through the session anchor (Refs #3286) external_exec_process set current_dir(cwd) unconditionally, so an 'exec <cmd> >> fifo' replacement spawn from a deleted session cwd failed the child's chdir with ENOENT (127 'cannot execute'). Carry stamp_spawn_cwd's three-outcome decision on ChildFdSetup and replay it in the exec Command builder: resolving cwd keeps current_dir, a dead cwd the anchor names becomes the same pre_exec fchdir the Command faces register, and a dead cwd no anchor names stays unstamped. --------- Co-authored-by: 曹梦轩 <[email protected]>
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.
Fixes #3286
What was fixed
In a deleted cwd, a relative output redirect to an existing FIFO failed instantly with ENOENT. The probe faces classified FIFO targets by joined-path metadata, which a dead cwd defeats. GNU opens the FIFO once in the child and blocks on the rendezvous until a reader arrives.
The fix removes the FIFO gates from
create_redirect_output(>) andopen_append_target(>>) and opens once via the cwd anchor (O_WRONLY|O_CREAT|O_TRUNC/O_WRONLY|O_CREAT|O_APPEND); the four probe entries now classify by anchorfstatatplus afaccessat(W_OK)check instead of joined-path metadata. Trap-execexec >/exec >>and compound-command binding (set_fd_output_file) go through the same anchor path.What was deleted
Nothing. No files, features, or tests were removed.
Verification (all run, per-item counts)
tests/issue3286_deleted_cwd_fifo_redirect.rs: 7/7 pass. Fail-first on the unpatched tree:>,>>, no-reader,exec >,exec >>all failed (instant ENOENT / leaked output); live-cwd and missing-parent controls passed.issue1820_fifo_redirect_regressions3/3,issue3268_deleted_cwd_cd_redirect19/19, 已删 cwd 下进程内路径串解析同族残差:comsub 内 cat、cd ..、壳侧输入重定向、模拟 cp 操作数面 #3268 family 12/12 + 9/9 + 10/10,issue2550_devfull_ambient7/7.third_party/bash):>/>>with reader, no-reader still blocked after 5 s,exec >/exec >>, missing-parent ENOENT — all agree with the pin expectations.issue1025_1026_1068_1103_1359_redirect_fd_regressions: 14/16 — the 2 failures are /dev/tcp output face: plain > opens the connection twice and delivers zero bytes with a write error (output-side sibling of #1950) #1967 net-redirect counting tests, reproduced as a pre-existing harness flake on the unpatched tree (4 runs: 3 fail / 1 pass), unrelated to this change.cargo build -j 2clean,cargo fmtclean.src/lexer/continuation.rsuntouched.Owed
exec <>../fifo(read-write face) still ENOENT in a deleted cwd; GNU succeeds. Same anchor shape asset_fd_output_file, left out of scope.cdredirects fail for all relative targets in a deleted cwd (pre-existing,open_cd_redirect_filedoes a barecwd.joinopen).write_to_fdempty-stream pairing branch still uses joined-path FIFO checks; no reproducer exists, left as analysed residue.stopbefore draining the backlog.