Skip to content

Commit 6ab8963

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. Resolve the target before the `exec`. `command -v` handles PATH names and absolute paths in every POSIX shell, 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 6ab8963

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,12 @@ 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". Resolve the target first; `command -v`
289+
// handles both PATH names and absolute paths in every POSIX shell.
290+
'command -v -- "$1" >/dev/null 2>&1 || exit 125',
285291
'exec "$@"',
286292
].join("\n"),
287293
"t3-acp-cgroup-wrapper",

0 commit comments

Comments
 (0)