






















@@ -86,24 +86,30 @@ describe("scripts/test-live", () => {
8686const root = mkdtempSync(join(tmpdir(), "openclaw-test-live-signal-"));
8787const fakePnpmPath = join(root, "pnpm");
8888const childPidPath = join(root, "child.pid");
89+const descendantPidPath = join(root, "descendant.pid");
8990const signaledPath = join(root, "signaled");
90919192writeFakePnpm(fakePnpmPath);
9293const runner = spawn(process.execPath, ["scripts/test-live.mjs", "--", "fake.live.test.ts"], {
9394env: {
9495 ...process.env,
9596OPENCLAW_FAKE_PNPM_PID_PATH: childPidPath,
97+OPENCLAW_FAKE_PNPM_DESCENDANT_PID_PATH: descendantPidPath,
9698OPENCLAW_FAKE_PNPM_SIGNALED_PATH: signaledPath,
9799npm_execpath: fakePnpmPath,
98100},
99101stdio: "ignore",
100102});
101103let childPid = 0;
104+let descendantPid = 0;
102105103106try {
104107await waitFor(() => fileExists(childPidPath), 5_000);
108+await waitFor(() => fileExists(descendantPidPath), 5_000);
105109childPid = Number(readFileSync(childPidPath, "utf8"));
110+descendantPid = Number(readFileSync(descendantPidPath, "utf8"));
106111expect(Number.isInteger(childPid)).toBe(true);
112+expect(Number.isInteger(descendantPid)).toBe(true);
107113108114expect(runner.pid).toBeGreaterThan(0);
109115process.kill(runner.pid!, "SIGTERM");
@@ -113,13 +119,17 @@ describe("scripts/test-live", () => {
113119await waitFor(() => fileExists(signaledPath), 5_000);
114120expect(readFileSync(signaledPath, "utf8")).toBe("SIGTERM");
115121await waitFor(() => !isProcessAlive(childPid), 5_000);
122+await waitFor(() => !isProcessAlive(descendantPid), 5_000);
116123} finally {
117124if (runner.pid && isProcessAlive(runner.pid)) {
118125process.kill(runner.pid, "SIGKILL");
119126}
120127if (childPid && isProcessAlive(childPid)) {
121128process.kill(childPid, "SIGKILL");
122129}
130+if (descendantPid && isProcessAlive(descendantPid)) {
131+process.kill(descendantPid, "SIGKILL");
132+}
123133rmSync(root, { force: true, recursive: true });
124134}
125135});
@@ -158,7 +168,15 @@ function writeFakePnpm(filePath: string): void {
158168filePath,
159169[
160170"#!/usr/bin/env node",
171+'const { spawn } = require("node:child_process");',
161172'const fs = require("node:fs");',
173+"if (process.env.OPENCLAW_FAKE_PNPM_DESCENDANT_PID_PATH) {",
174+" const child = spawn(process.execPath, [",
175+' "-e",',
176+" \"process.on('SIGTERM', () => {}); setInterval(() => {}, 1000);\",",
177+" ], { stdio: 'ignore' });",
178+" fs.writeFileSync(process.env.OPENCLAW_FAKE_PNPM_DESCENDANT_PID_PATH, String(child.pid));",
179+"}",
162180"fs.writeFileSync(process.env.OPENCLAW_FAKE_PNPM_PID_PATH, String(process.pid));",
163181'process.on("SIGTERM", () => {',
164182' fs.writeFileSync(process.env.OPENCLAW_FAKE_PNPM_SIGNALED_PATH, "SIGTERM");',
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。