mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-02 19:15:16 +00:00
fix: parse qa parent pid strictly
This commit is contained in:
@@ -13,6 +13,10 @@ describe("installQaParentWatchdog", () => {
|
||||
expect(
|
||||
installQaParentWatchdog({ env: { [QA_PARENT_PID_ENV]: "not-a-pid" }, ownPid: 10 }),
|
||||
).toBeNull();
|
||||
expect(
|
||||
installQaParentWatchdog({ env: { [QA_PARENT_PID_ENV]: "0x10" }, ownPid: 10 }),
|
||||
).toBeNull();
|
||||
expect(installQaParentWatchdog({ env: { [QA_PARENT_PID_ENV]: "1e3" }, ownPid: 10 })).toBeNull();
|
||||
});
|
||||
|
||||
it("exits when the QA parent process disappears", async () => {
|
||||
|
||||
@@ -40,7 +40,7 @@ function resolveQaParentPid(env: NodeJS.ProcessEnv, ownPid: number): number | nu
|
||||
if (!raw) {
|
||||
return null;
|
||||
}
|
||||
const parentPid = Number(raw);
|
||||
const parentPid = /^\d+$/.test(raw) ? Number(raw) : Number.NaN;
|
||||
if (!Number.isSafeInteger(parentPid) || parentPid <= 0 || parentPid === ownPid) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user