You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[bug] Redirection leaks past a top-level command spawning $THIS_SH script.sh (in-process re-exec suspect): following output written into the redirect file #164
Activity
caomengxuan666 commentedon Sep 26, 2026
根因已定位并修复(wt/m1-here f30ecfb3,待 captain 验收合入)
根因:
execute_direct_shell_script(src/executor/external_finish.rs)用open_compound_output_redirects把命令重定向绑到共享 Executor 上(fd 表条目 +fd_output_key(1)env 通道),但从不撤销;而saved_env与saved_fd_table都在绑定之后才快照,于是restore_shell_env(saved_env)与fd_table = saved_fd_table把子进程的 fd-1 绑定原样还原进了父进程——后续echo DONE5继续写进 o.tmp。回归引入点:4fe2a48f(_bound_output_fds守卫加入时两个快照已在绑定之后)。GNU 规范:execute_cmd.c:5771 execute_disk_command——fork 出的子进程在 :5884 自行
do_redirections (redirects, RX_ACTIVE)(不可撤销),随子进程消亡;父进程从不绑定外命令的重定向。进程内仿真必须镜像该进程边界。修复:子进程跑完、父状态还原之后补一句
restore_compound_output_redirects(bound_output_fds)(绑定时刻记录的前状态回放,含 exit-trap 保持在子作用域内)。无任何 fast-path 谓词改动。验证(双侧脚本文件,WSL GNU Bash 5.3.0):
[DONE5]、o.tmp[hB],与 GNU 一致。3>f对$SH -c子进程不绑 fd,基线即如此,stash 验证与本修复无关,已开 [bug] 编号 fd 重定向对进程内 $SH -c 子进程不生效: "$SH" -c 'echo N3 >&3' 3>f 报 3: Bad file descriptor(GNU 写入 f) #180)。cargo check --tests× linux-gnu/darwin 干净、rustfmt 干净。排障中新发现(另开单):#179 双引号内 comsum + glob 元字符(
* ? [)时 CTLESC\x11载波泄漏进 echo/printf 输出——echo "A[$(cat f)]"诊断形态全污染。redir: undo in-process child-script fd bindings after the child exits…
caomengxuan666 commentedon Sep 26, 2026
已在 master 落地(f30ecfb3 + captain 合并解冲突):根因=execute_direct_shell_script 在共享 Executor 上绑 fd-1(open_compound_output_redirects),但 saved_env/saved_fd_table 都在绑定之后快照——父进程的两路恢复反而把子脚本的输出绑定重装回父进程(4fe2a48f 引入)。修法=子退出后按绑定时刻捕获的状态重放 restore_compound_output_redirects,镜像 GNU 的进程边界(execute_cmd.c:5771/:5884——重定向只在 fork 的子进程里生效)。验证:t6 复现与 GNU 一致;17 形态泄漏×作用域矩阵一致(唯一差=既有的 #180 编号 fd 未绑);474/474 + 双交叉;captain 合并后亲手复验泄漏清零(子脚本 >file 后父进程输出不再落 file)。与 L-K 的 fresh_shell 重构合并无冲突语义。
fix(executor): resolve virtual system-root argv through the root map …