Skip to content

Commit 39b18b9

Browse files
Moinaxclaude
andcommitted
fix(server): a missing agent binary no longer reads as a wrapper kill
The Linux cgroup wrapper reserves 125 for "could not start the target" and produces it with `trap 'exit 125' 0`. That trap does not cover a failed `exec`: dash runs the EXIT trap, bash does not. Where `/bin/sh` is bash — Arch and its derivatives — a missing agent binary exits 127 instead, and the session reports the wrapper as having killed the agent rather than never having launched it. Test the target before the `exec`. The caller always hands the wrapper an absolute path — `spawnCommand.command` when it is already absolute, otherwise `resolveLinuxCgroupTargetCommand`'s result — so `[ -f ] && [ -x ]` is the whole check, and it mirrors the `statSync`/`X_OK` pair that resolver already applies on the Node side. No shell option or PATH parsing is involved, so the documented 125 holds whichever shell `/bin/sh` is. The expected behaviour is already pinned by the missing-target assertion in AcpSessionRuntime.processTree.test.ts, which fails with "expected 127 to be 125" on a bash-as-/bin/sh host without this. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
1 parent 71dbaf1 commit 39b18b9

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎apps/server/src/provider/acp/AcpSessionRuntime.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,13 @@ export function wrapCommandForLinuxCgroup(
282282
'[ "$actual" = "$expected" ] || exit 126',
283283
"unset ELECTRON_RUN_AS_NODE T3_ACP_CGROUP_WRAPPER",
284284
"trap 'exit 125' 0",
285+
// The trap alone does not cover a failed `exec`: bash — which is
286+
// /bin/sh on Arch derivatives — exits 127 without running the EXIT
287+
// trap, so a missing agent binary reported "killed by the wrapper"
288+
// instead of "never launched". The caller always hands us an absolute
289+
// target, so test it as an executable file rather than asking the
290+
// shell to resolve it.
291+
'[ -f "$1" ] && [ -x "$1" ] || exit 125',
285292
'exec "$@"',
286293
].join("\n"),
287294
"t3-acp-cgroup-wrapper",

0 commit comments

Comments
 (0)