From 1d992cf9dc30c4b0f8203b3b2cb165acdafbfa89 Mon Sep 17 00:00:00 2001 From: jkooe <62494645+jkooe@users.noreply.github.com> Date: Sun, 27 Sep 2026 02:39:16 +0800 Subject: [PATCH] =?UTF-8?q?fix(agent):=20=E8=B6=85=E6=97=B6=E5=BC=BA?= =?UTF-8?q?=E6=9D=80=E7=9A=84=20exit=5Fcode=20=E8=B7=A8=E5=B9=B3=E5=8F=B0?= =?UTF-8?q?=E5=BD=92=E4=B8=80=E4=B8=BA=20124?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Windows 上 taskkill /F 会让子进程以 code=1 退出(Unix 为 null), 原逻辑 code ?? (killed ? 124 : -1) 在 Windows 上会返回 1。 改为 killed 优先:被杀统一返回 124,与 Unix timeout(1) 语义一致。 CI 实机验证发现:Windows 上 12/13 → 修复后应 13/13 --- apps/agent/src/util/exec.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/agent/src/util/exec.ts b/apps/agent/src/util/exec.ts index b8c8f19..2ddd09a 100644 --- a/apps/agent/src/util/exec.ts +++ b/apps/agent/src/util/exec.ts @@ -116,7 +116,9 @@ export function execCommand(opts: ExecOptions): Promise { const finish = (code: number | null): void => { clearTimeout(timer); resolve({ - exit_code: code ?? (killed ? 124 : -1), + // 被超时强杀时统一语义:exit_code = 124(与 Unix timeout(1) 惯例一致) + // 注:Windows 上 taskkill /F 会让子进程以 code=1 退出(Unix 为 null),需在此归一 + exit_code: killed ? 124 : (code ?? -1), stdout: stdout.trimEnd(), stderr: stderr.trimEnd(), duration_ms: Date.now() - startedAt,