Repository navigation
fix(executor): wire every pipeline stage's fd 2 from the fd table on the Windows and shell-stage spawn paths (Refs #3402) - #3562
Conversation
…the Windows and shell-stage spawn paths (Refs #3402) GNU execute_cmd.c:2620 execute_pipeline forks every element with the shell's fd 2 exactly as redir.c:237 do_redirections bound it. #3308 wired the Unix concurrent twins; the remaining spawn loops still left non-last members on the raw process stderr past an enclosing `2>file` / `2>/dev/null` / `2>&-` / `exec 2>file` binding: - Windows spawn_wait_concurrent_external_stages (all-external and prefix-concurrent paths) only wired fd 2 for the `2>&1` merge, and execute_external_pipeline_concurrently relayed the last stage's collected stderr through std::io::stderr(); - the prefix streaming tail gated the #3308 plan to non-Windows; - the streaming sandwich (one shell-side stage) and the shell-writer consumer loop never wired non-last members at all (both platforms). ConcurrentPipelineStderr and its resolver are now platform-neutral and carry a `wire` helper; every loop resolves the plan once and relays a Piped member through write_default_stderr. Pin: tests/issue3402_pipeline_stage_stderr_fd_table.rs (18 cells, one per spawn path x binding, plus two GNU-correct controls). Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…te stderr (Fixes #3566) The Windows prefix-concurrent driver (execute_external_prefix_concurrently caller) assigned the prefix's stdout to the next stage's input only in the merged and the stderr-empty arms; a prefix whose last member wrote any stderr with fd 2 not merged relayed the diagnostic and handed the shell-side stages an empty input. GNU execute_cmd.c:2620 execute_pipeline gives each member an fd 1 pipe independent of its fd 2, so the payload is unconditional. Pin: two more cells in tests/issue3402_pipeline_stage_stderr_fd_table.rs (fail-first 18/2 -> 20/0). Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
【WIN-AGENT-AUDIT】s10 lane — 建议:PENDING(CONFLICTING,跳过不合) head: 3995c71 base(merge-base): 8b48c16 文件: 2 个 +404/-65 处置:不合并。 背景提示(供续作参考):
腿:本轮全部未跑(按 CONFLICTING 跳过规则),不记为通过。 未跑/VOID 的腿:
|
|
【WIN-AGENT-AUDIT】 head: 3995c71 mergeable=CONFLICTING/DIRTY;关联 issue #3402(open,我核过的时间:本地 2026-11-18) 两者修的不是同一不变量:
GNU 语义(third_party/bash @9c465866 复核):execute_cmd.c:2620 execute_pipeline 给每个成员 fork 管道、继承 shell 当时的 fd 2;成员自身的 完整性与定序:#3509 范围窄但修的是挂死(严重度高),先合正确;#3562 覆盖 5 条 spawn 路径的 ambient 面,范围更广、属正确性误路由,issue #3402 未关,仍需要。定序事实已成立:#3509(3d8c9ff8)与 #3860(9d00b569,ANCESTOR-OK,已把本 PR 内的 #3566 #3562 rebase 续作要点(供队长/续作,非本轮判词):
裁决:#3562 不废弃、保持 draft;定序 = #3509(已合)→ #3860(已合)→ #3562 rebase 续作。本评论不合并、不关闭任何 PR。 未跑/VOID 的腿:无(纯裁决评论,未动代码;机制对照引自 third_party/bash 源码与 gh/git 只读核验)。 |
Resolve pipeline_exec.rs against #3509 (member-own 2> redirects via configure_stage_stderr/stage_has_stderr_redirect) and #3860 (#3566 prefix stdout): wire() lays the ambient fd-table default first, then configure_stage_stderr applies the member's own redirect (the do_piping -> do_redirections order); Piped drains keep the child.stderr.take() guard; spawn-failure diagnostics ride write_default_stderr like the unix twin.
|
【WIN-AGENT-AUDIT】PR #3562 第2轮 — 建议:PASS 机制核查:
腿(逐项):
F 点:无 续作记录:
未跑/VOID 的腿:
|
|
【WIN-AGENT-BATCH-SUMMARY】l3 波次完成(Windows 面两条收尾)
|
Fixes #3402
修了什么
流水线成员的 fd 2 在 #3308 之后仍有多条 spawn 路径绕过 fd 表、直接继承/写入进程原始 stderr,导致外层
2>file/2>/dev/null/2>&-/exec 2>file对非末成员(以及 Windows 全外部路径的末成员中继)无效:spawn_wait_concurrent_external_stages(全外部并发 + 前缀并发)2>&1合并时接线,其余继承原始 stderrexecute_external_pipeline_concurrently末成员中继std::io::stderr().write_all(议题点名的 raw write)execute_external_prefix_streaming_tail(builtin 尾)cfg(not(windows))挡掉execute_streaming_sandwich_pipeline(一个 shell 侧成员)execute_shell_writer_pipeline消费者循环2>&1时接线机制修法:
ConcurrentPipelineStderr枚举与concurrent_pipeline_stderr_plan()去掉cfg(not(windows))(fd 表与duplicate_handle_inheritable两平台都有),新增ConcurrentPipelineStderr::wire()统一接线;上表每个 spawn 循环在循环前解析一次 plan、按 plan 接线,Piped成员自 spawn 起排水、收割后经write_default_stderr按成员序中继(2>&1即走 dup 时快照,不再走write_default_stdout喂进活 capture)。原 Unix 孪生与 streaming tail 里两份手写 match 也收拢到wire(),行为不变。删了什么
std::io::stderr().write_all原始写。#[cfg(not(windows))]门控。wire())。无文件、功能、测试被删除。
GNU 依据
execute_cmd.c:2620 execute_pipeline():每个成员都 fork 到 OS 管线,子进程继承 shell 当时的 fd 2。redir.c:237 do_redirections():外层/成员自身重定向在成员内生效 —— 外层2>file即每个成员的 fd 2。2>&1的 dup 快照语义(redir.cdup2 路径,[bug][fd] 脚本模式 $(外部 | 外部):管道首进程 stderr 绕过全部重定向直写控制台(-c 模式正常;GNU 无此行为) #3308 已引用redir.c:1170):中继走 fd 2 自身绑定。验证(Windows 本机,逐 stem 报数)
tests/issue3402_pipeline_stage_stderr_fd_table.rs(18 格:每条 spawn 路径 × devnull / err 文件 /2>&-/exec 2>file/2>&1捕获,外加 2 个 GNU 正确"泄漏"对照格防过度抑制):git checkout origin/master -- src/executor/pipeline_exec.rs重建)fail-first 3 passed / 15 failed,红格恰为缺陷格(绿的是2>&1捕获格与两个对照格)。/usr/local/bin/bash,脚本文件,独立 cwd):stdout / stderr / err.txt 与钉期望全一致。PATH=/usr/bin:/bin找不到cat、2>{}内插 Windows 反斜杠路径等),与本改动无关。rustfmt --edition 2021 --check覆盖cargo metadata列出的全部 1487 个 target 源:本 PR 文件全净;唯一 diff 是 master 既有的tests/d11_pipeline_squote_carrier_regressions.rs(非本 PR)。Owed
cargo check --tests),新钉在 Windows 上仅本机跑过。cargo fmt --check因 1487 个 target 路径超出 Windows 命令行上限报os error 206必然失败(与改动无关,主仓库同样复现),本次提交以等价的逐文件rustfmt --check全量校验代替,钩子未能执行 —— 如实说明。