fix(qa-lab): kill script timeout trees on windows · openclaw/openclaw@a6e41a0
vincentkoc
·
2026-06-20
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -186,6 +186,27 @@ function formatCommand(step: QaScenarioCommandStep) {
|
186 | 186 | return [step.command, ...step.args].map(shellQuote).join(" "); |
187 | 187 | } |
188 | 188 | |
| 189 | +function killQaScenarioWindowsProcessTree(pid: number | undefined, signal: NodeJS.Signals) { |
| 190 | +if (pid === undefined) { |
| 191 | +return false; |
| 192 | +} |
| 193 | +const args = ["/pid", String(pid), "/T"]; |
| 194 | +if (signal === "SIGKILL") { |
| 195 | +args.push("/F"); |
| 196 | +} |
| 197 | +try { |
| 198 | +const killer = spawn("taskkill", args, { |
| 199 | +stdio: "ignore", |
| 200 | +windowsHide: true, |
| 201 | +}); |
| 202 | +killer.on("error", () => undefined); |
| 203 | +killer.unref(); |
| 204 | +return true; |
| 205 | +} catch { |
| 206 | +return false; |
| 207 | +} |
| 208 | +} |
| 209 | + |
189 | 210 | function runQaScenarioCommand( |
190 | 211 | execution: QaScenarioCommandExecution, |
191 | 212 | ): Promise<QaScenarioCommandResult> { |
@@ -236,6 +257,11 @@ function runQaScenarioCommand(
|
236 | 257 | // The process group may already be gone; fall back to the direct child. |
237 | 258 | } |
238 | 259 | } |
| 260 | +if (!useProcessGroup && process.platform === "win32") { |
| 261 | +if (killQaScenarioWindowsProcessTree(child.pid, signal)) { |
| 262 | +return; |
| 263 | +} |
| 264 | +} |
239 | 265 | child.kill(signal); |
240 | 266 | }; |
241 | 267 | const handleParentExit = () => { |
@@ -346,6 +372,9 @@ function runQaScenarioCommand(
|
346 | 372 | signal, |
347 | 373 | ...(timedOut ? { failureMessage: `${commandLabel()} timed out after ${timeoutMs}ms` } : {}), |
348 | 374 | }; |
| 375 | +if (timedOut && !useProcessGroup && (forceKillTimer || forceSettleTimer)) { |
| 376 | +return; |
| 377 | +} |
349 | 378 | if (isProcessGroupRunning()) { |
350 | 379 | if (!timedOut) { |
351 | 380 | signalChild("SIGTERM"); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。