Repository navigation
WIP: fix(executor): model the write endpoint of a function call's <> fd 0 - #2260
Merged
Merged
Conversation
…(rubash#2249) A <> redirect on a function call is GNU's r_input_output (make_cmd.c:682-683: flags O_RDWR|O_CREAT; redir.c:725 redir_open) — one descriptor serving both directions. function_call_stdin was the only <> face binding FileFd::open_read alone, so a body write like echo x >&0 failed Bad file descriptor. Bind the read-write pair (FileFd::open_readwrite_pair, one open file description with a shared offset) for regular files and devices/fifos, bind the connected socket in both directions for net targets, and extend the binding's undo contract to the fd-0 env keys the bind overwrites, mirroring set_fd_readwrite_file's bookkeeping. The operand keeps the #2240 anchored ladder. Also anchor execute_direct_shell_script's fd-0 install in external_finish.rs with the same ladder: the bare mapped path resolved against the startup directory and silently bound a same-named decoy file as the child's live fd 0 after a cd. Regression pins: tests/issue2249_function_readwrite_fd0_regressions.rs (9 pins, GNU bash 5.3.20 oracle expectations). Local verification per the compile-rationing regime: cargo check only; test execution is deferred to the batch compile (probes/run-probes.sh in the cluster workdir). Refs: #2249
caomengxuan666
marked this pull request as ready for review
October 30, 2026 17:01
This was referenced Oct 30, 2026
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 写面建模 + 子脚本 fd-0 安装补梯Refs: #2249
改动
① 函数
<>写面(src/executor/function_calls.rs)function_call_stdin是全仓唯一只绑读端点的<>面。GNU<>是 r_input_output(make_cmd.c:682-683,flags = O_RDWR|O_CREAT;redir.c:725 redir_open)——单一描述符双向服务。现按其余各面同一机制(set_fd_readwrite_file/FileFd::open_readwrite_pair)补齐:② 子脚本 fd-0 安装补梯(src/executor/external_finish.rs)
execute_direct_shell_script的 file_stdin 安装由裸shell_path_to_windows改为 #2240 同梯(windows_operand_file_path + session_path,含空操作数不 join)。原形状在 cd 后若启动目录有同名诱饵文件,会把诱饵绑成子脚本的真实 fd-0 端点(回退通道只在无诱饵时掩盖)。回归钉
tests/issue2249_function_readwrite_fd0_regressions.rs(9 条):写落盘、共享偏移判别格(读 2 字节后写落偏移 2)、返回后恢复契约、cd 后锚定、O_CREAT 创建、定义时重定向、/dev/null、编号 fd 对照、子脚本诱饵格。期望全部按 GNU bash 5.3.20 oracle 脚本实跑写死。验证(编译配给制)
本地只做
cargo check --lib --tests(exit 0)+ rustfmt + GNU oracle 探针实跑存档;回归钉与 rubash 侧探针未在本地实跑,待批量编译补验(探针与运行器在主会话工作区 fix-2249-fd0-write/probes/)。全量门走本 PR CI。