Repository navigation
fix(executor): seat raw-fork async children via the cwd anchor fd (Refs #3420) - #3438
Conversation
#3420) GNU: the session cwd IS the process cwd (builtins/cd.def:600 change_to_directory moves it with chdir); the async child is a fork that inherits it (execute_cmd.c:2811 execute_connection '&' branch; execute_cmd.c:5771 execute_disk_command forks via make_child with no chdir in the child). A background external spawned from a deleted cwd is therefore silent with rc 0. rubash keeps the session cwd as a field and the raw-fork direct spawn seated the child with a path-string libc::chdir, which fails once the directory is unlinked: the diagnostic reached the shell's own stderr (before dup2) and the job exited 1. Pass the cwd anchor fd (session_cwd_anchor_fd - the same two-state ask stamp_spawn_cwd makes for Command spawns) into raw_fork_async_child; the child fchdirs the anchor first (it wins over a ghost path recreated at the same spelling) and falls back to the path spelling when there is no anchor. The anchor fd is counted in max_fd so the close loop takes it before exec. UNVERIFIED-BY-CAPTAIN
A match-arm body ending in a block is taken as the arm's end, so
'Some(fd) => unsafe { libc::fchdir(fd) } == 0' fails to parse with
'expected pattern, found ==' (CI: exactly 1 compile error, all legs
failed on it). Parenthesize the unsafe block so the comparison parses
as the arm expression. No semantic change: anchor fchdir first, path
chdir fallback, diagnostic + exit 1 only when both fail.
UNVERIFIED-BY-CAPTAIN
Mechanical rustfmt fix on the new pin file (single long assert! line re-wrapped); no semantic change. Found while verifying the compile-fix commit: the first lane had no rustfmt available. UNVERIFIED-BY-CAPTAIN
PR #3438 复核评论稿(DRAFT——只起草,不发;由队长发)判词:FAIL — 钉-only 返工(产品码已验,无产品缺陷)复核员:队长复核员(续跑轮)。对象:PR #3438(Refs #3420,draft, 已验通过
返工项(两处,只改钉文件,不动产品码)
返工后重审须跑钉双边(base 3/7 fail-first 逐名 + head 7/7)、 环境说明(非产品问题)本轮构建腿全阻于环境,非判词依据:本地写墙秒级震荡关闭 |
… pin (Refs #3420) Each of the seven cells pre-created `<scratch>/a` on the Rust side, so the script's `mkdir a` reported `File exists` to stderr and every cell failed the empty-stderr assertion. Removing the calls lets the script create the directory itself. `Scratch::mkdir` and `Scratch::touch` are dead after the removal (zero callers; `touch` was already dead) and would fail test-target compilation under `-D warnings`. Refs #3420
Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
【WIN-AGENT-AUDIT】 机制核查:
腿(X299 Windows 本机):
F 点回应:
续作记录:
未跑/VOID 的腿:
|
|
【WIN-AGENT-REWORK】 PR #3438 第3轮 — 建议:PASS(缺腿补齐) 本轮补腿(WSL Linux /root/rubash-wsl,CARGO_INCREMENTAL=0,-j 2):
未动代码;其余腿按第2轮审计记录全绿。判词翻 PASS,按协议 squash 合并。 |
Refs #3420 — UNVERIFIED-BY-CAPTAIN
根因
GNU bash 5.3.20:会话 cwd 就是进程 cwd(builtins/cd.def:600
change_to_directory以chdir移动);异步子进程是 fork 继承而来(execute_cmd.c:2811execute_connection的&分支;execute_cmd.c:5771execute_disk_command经make_childfork,子进程内无 chdir)。因此从已删除 cwd 生成的后台外部命令应静默、rc 0。rubash 把会话 cwd 存为字段,raw-fork 直发(
spawn_async_direct→raw_fork_async_child,src/executor/external_inner.rs)以路径串libc::chdir给子进程落位;目录一旦 unlink 即失败,诊断印到壳自身 stderr(dup2 之前,绕过作业的2>重定向),作业 rc 1。修法
把 cwd anchor fd(
session_cwd_anchor_fd——与stamp_spawn_cwd对Command生成点做的同一 two-state ask)传入 raw-fork 子进程:子进程先 fchdir anchor(anchor 在同拼写 ghost 路径上胜出),无 anchor 时回落路径串 chdir;两者皆败才印诊断、退 1。anchor fd 计入 max_fd,exec 前由 close 循环收走(与其它继承 fd 同规则)。只改src/executor/external_inner.rs一文件(+39/−9),未碰src/lexer/continuation.rs,未改docs/api-ledger.md,未引入任何 trust/签名/加载期校验机制。探针(GNU 5.3.20 oracle,三方,probe-3420.sh)
chdir: …: No such file or directory、bg-rc=1。ls >../out 2>../err &):同上(自删除 inode 解析..)。false)、C1g(缺命令 127)为对照:基底与 GNU 同。回归钉
新钉
tests/issue3420_bg_spawn_deleted_cwd_anchor.rs(7 格:C1a/C1b/C1c/C1d 为 fail-first 分歧形,C1e/C1f/C1g 为对照)。钉期望逐格以 GNU oracle 实测为准。本地腿未跑(本轮 box 构建槽满、本地禁 cargo build):钉双边、lib 双边、
-D warnings、卫生腿待队长复核轮在 X299/box 上跑。CI 编译即首道验证。本 PR 删除了什么
无删除。本 PR 只给 raw-fork 子进程加一条 anchor fchdir 兜底并新增一支回归钉:无文件删除、无公开 API 删除、无行为删除;唯一行为变化是删除 cwd 内后台外部生成不再报
chdir:失败(按 GNU 静默 rc 0)。