惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
B
Blog RSS Feed
量子位
aimingoo的专栏
aimingoo的专栏
V
Visual Studio Blog
Y
Y Combinator Blog
Vercel News
Vercel News
云风的 BLOG
云风的 BLOG
宝玉的分享
宝玉的分享
Engineering at Meta
Engineering at Meta
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
GbyAI
GbyAI
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
Stack Overflow Blog
Stack Overflow Blog
大猫的无限游戏
大猫的无限游戏
Microsoft Security Blog
Microsoft Security Blog
B
Blog
Last Week in AI
Last Week in AI
有赞技术团队
有赞技术团队
博客园 - 聂微东
腾讯CDC
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
J
Java Code Geeks

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(infra): narrow inherited gateway pid protection · ope...
vincentkoc · 2026-06-16 · via Recent Commits to openclaw:main

@@ -383,68 +383,6 @@ describe.skipIf(isWindows)("restart-stale-pids", () => {

383383

},

384384

);

385385386-

it("excludes the inherited gateway service PID when the caller has been reparented to launchd — suicide-kill regression", () => {

387-

// Regression for the rh-bot SIGKILL cycle diagnosed 2026-06-05.

388-

//

389-

// Scenario: a user `~/.zshrc` contains a legacy auto-start block

390-

// `(openclaw gateway >/dev/null 2>&1 &)`

391-

// and codex 0.135.0 spawns `/bin/zsh -c "set -e; . shell_snapshot"`

392-

// per turn for tool execution context. The backgrounded subshell

393-

// exits, the new `openclaw gateway` is reparented to launchd

394-

// (process.ppid === 1), and the ancestor walk can no longer see the

395-

// launchd-managed parent gateway. lsof reports the parent gateway

396-

// on the port, the cleanup SIGKILLs it, launchd respawns it via

397-

// `KeepAlive: { Crashed: true }`, and the cycle repeats on every

398-

// chat request.

399-

//

400-

// Fix: the gateway-cli captures `OPENCLAW_GATEWAY_SERVICE_PID` from

401-

// its inherited env BEFORE overwriting it with `process.pid`, then

402-

// hands the captured value to `cleanStaleGatewayProcessesSync`.

403-

// The cleanup adds it to the exclusion set so the parent gateway

404-

// is left alone even though it is now an unrelated sibling on the

405-

// port from the caller's perspective.

406-

const launchdManagedGatewayPid = process.pid + 4001;

407-

const unrelatedStalePid = process.pid + 4002;

408-

mockSpawnSync.mockReturnValue({

409-

error: null,

410-

status: 0,

411-

stdout: lsofOutput([

412-

{ pid: launchdManagedGatewayPid, cmd: "openclaw-gateway" },

413-

{ pid: unrelatedStalePid, cmd: "openclaw-gateway" },

414-

]),

415-

stderr: "",

416-

});

417-

// Stub ppid to 1 (launchd) so the ancestor walk cannot reach the

418-

// running gateway. Without the inherited-PID protection, the

419-

// launchd-managed gateway PID would be returned and killed.

420-

const pids = withStubbedPpid(1, () =>

421-

findGatewayPidsOnPortSync(18789, undefined, launchdManagedGatewayPid),

422-

);

423-

expect(pids).not.toContain(launchdManagedGatewayPid);

424-

expect(pids).toContain(unrelatedStalePid);

425-

});

426-427-

it("ignores a non-positive inherited gateway PID rather than poisoning the kill list", () => {

428-

// Defensive: callers may pass undefined or zero when the env var is

429-

// missing or malformed. The helper must treat those as no-op rather

430-

// than excluding pid 0 (which would silently mask a genuine kernel

431-

// pid 0 listener — there is no such thing in practice, but the

432-

// guard documents the contract).

433-

const stalePid = process.pid + 4101;

434-

mockSpawnSync.mockReturnValue({

435-

error: null,

436-

status: 0,

437-

stdout: lsofOutput([{ pid: stalePid, cmd: "openclaw-gateway" }]),

438-

stderr: "",

439-

});

440-

const pidsUndef = findGatewayPidsOnPortSync(18789, undefined, undefined);

441-

const pidsZero = findGatewayPidsOnPortSync(18789, undefined, 0);

442-

const pidsNegative = findGatewayPidsOnPortSync(18789, undefined, -1);

443-

expect(pidsUndef).toContain(stalePid);

444-

expect(pidsZero).toContain(stalePid);

445-

expect(pidsNegative).toContain(stalePid);

446-

});

447-448386

it("excludes PID 1 when the direct parent gateway is the container entrypoint — container topology", () => {

449387

// Codex P1: in container deployments the gateway is the container

450388

// entrypoint and therefore runs as PID 1 of its namespace. A sidecar

@@ -860,6 +798,32 @@ describe.skipIf(isWindows)("restart-stale-pids", () => {

860798

expect(killSpy).toHaveBeenCalledWith(stalePid, "SIGTERM");

861799

});

862800801+

it("does not kill a protected gateway pid after reparenting", () => {

802+

const protectedPid = process.pid + 4001;

803+

const stalePid = process.pid + 4002;

804+

let lsofCall = 0;

805+

mockSpawnSync.mockImplementation(() => {

806+

lsofCall += 1;

807+

return lsofCall === 1

808+

? createLsofResult({

809+

stdout: lsofOutput([

810+

{ pid: protectedPid, cmd: "openclaw-gateway" },

811+

{ pid: stalePid, cmd: "openclaw-gateway" },

812+

]),

813+

})

814+

: createLsofResult({ status: 1 });

815+

});

816+

const killSpy = vi.spyOn(process, "kill").mockReturnValue(true);

817+818+

const result = withStubbedPpid(1, () =>

819+

cleanStaleGatewayProcessesSync(18789, { protectedPid }),

820+

);

821+822+

expect(result).toEqual([stalePid]);

823+

expect(killSpy).toHaveBeenCalledWith(stalePid, "SIGTERM");

824+

expect(killSpy).not.toHaveBeenCalledWith(protectedPid, expect.anything());

825+

});

826+863827

it("escalates to SIGKILL when process survives the SIGTERM window", () => {

864828

const stalePid = process.pid + 101;

865829

let call = 0;