Skip to content

WIP: fix(executor): model the write endpoint of a function call's <> fd 0 - #2260

Merged
caomengxuan666 merged 2 commits into
masterfrom
fix/2249-fd0-write
Oct 30, 2026
Merged

caomengxuan666 merged 2 commits into
masterfrom
fix/2249-fd0-write

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

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。

caomengxuan666 and others added 2 commits October 30, 2026 16:52
…(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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant