Repository navigation
WIP: fix(executor): bind the read-write pair for a child script's <> fd 0 - #2267
Merged
Merged
Conversation
Refs #2261. execute_direct_shell_script's fd-0 install bound FileFd::open_read for every file target, so a child script run with `<>file` got only the read endpoint of fd 0 and `echo x >&0` inside the child failed Bad file descriptor. GNU's `<>` is r_input_output (make_cmd.c:682-683 — O_RDWR|O_CREAT; redir.c:725 redir_open): one descriptor serving both directions over one open file description. Mirror the function-call face (function_call_stdin, rubash#2249): for a ReadWrite redirect the install now binds FileFd::open_readwrite_pair on the same #2240 operand ladder and applies the fd-0 output env bookkeeping (fd_output_key(0), mirroring save_and_apply_fd0_readwrite_env). The undo is the site's existing whole fd-table / env save-restore around the child run. A failed pair open and net targets keep the function_call_stdin fall-through, as plain `<` does. Pins: tests/issue2261_child_script_readwrite_fd0_regressions.rs (9). Expectations measured against GNU bash 5.3.20 (script-file probes probeP1-probeP10 in the cluster workdir).
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: 子脚本
<>fd-0 安装改绑读端点对(#2249 函数面姊妹面)Refs #2261
定性
execute_direct_shell_script(external_finish.rs)的 file_stdin 安装对一切文件目标都绑FileFd::open_read——./child.sh <>f.txt时子脚本只拿到 fd 0 的读端点,体内echo x >&0报 Bad file descriptor。GNU 的<>是 r_input_output(make_cmd.c:682-683 给 O_RDWR|O_CREAT,redir.c:725 redir_open 执行打开):单一描述符双向、共享偏移。基线形状补充(读码定性):目标已存在时只读安装获胜(issue 形状);目标不存在时 open_read 失败、落到 function_call_stdin 的
<>臂以副作用绑 pair(binding 在此调用点被丢弃),该形状可能已偶然通;<>目录时 open_read 在 Unix 可成功、子脚本误跑(GNU 应 EISDIR 不跑)。修复(单文件 +39/−2)
FileFd::open_readwrite_pair(与 函数 <> 重定向的 fd-0 写面未建模(echo x >&0 报 Bad file descriptor) #2249 函数面function_call_stdin同一机制),操作数沿用本安装点已有的 函数调用的输入重定向相对路径按进程启动 cwd 解析、cd 后 ENOENT(#2211 姊妹) #2240 解析梯(WIP: fix(executor): model the write endpoint of a function call's <> fd 0 #2260 补齐,未重复动)。fd_output_key(0)+ 清 proc-sub 键,镜像save_and_apply_fd0_readwrite_env);undo 依托本安装点既有的整 fd 表 / 整 env 快照恢复(与函数面 per-binding save/restore 等价的契约)。<同路由)。回归钉
tests/issue2261_child_script_readwrite_fd0_regressions.rs9 条(写落盘 / 共享偏移判别格 / O_CREAT 创建 / 父 fd 0 恢复 / cd 锚写面 / 目录 EISDIR / 编号3<>对照 / 普通<两对照),期望全部按 GNU bash 5.3.20 oracle 脚本文件实测(探针 probeP1–P10 + expected/ 在簇工作区)。相邻面 issue2249 / issue2240 已在钉头列明不回退要求。<> /dev/null仅作探针观察(P8),未落钉,理由见簇 REPORT。验证分栏(编译配给制)
cargo check --lib --testsexit 0(本簇两文件零警告);逐文件 rustfmt clean;CR=0;GNU oracle 探针全跑存档。