From 1871da1fb32d6b9d5afce45138bd850ec3c19935 Mon Sep 17 00:00:00 2001 From: Jeremy McSpadden Date: Mon, 16 Mar 2026 17:41:36 -0500 Subject: [PATCH] fix: use process.ppid instead of PID 1 for cross-platform test PID 1 (init) exists on Unix but not on Windows, causing the cross-process detection test to fail in CI. Use process.ppid (parent process) which is guaranteed alive on all platforms. --- .../extensions/gsd/tests/auto-lock-creation.test.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/resources/extensions/gsd/tests/auto-lock-creation.test.ts b/src/resources/extensions/gsd/tests/auto-lock-creation.test.ts index b3ffbc991..2694e8820 100644 --- a/src/resources/extensions/gsd/tests/auto-lock-creation.test.ts +++ b/src/resources/extensions/gsd/tests/auto-lock-creation.test.ts @@ -139,9 +139,11 @@ test("lock file enables cross-process auto-mode detection", () => { const dir = mkdtempSync(join(tmpdir(), "gsd-lock-test-")); mkdirSync(join(dir, ".gsd"), { recursive: true }); - // Simulate another process writing a lock with PID 1 (init — always alive on Unix) + // Use the parent process PID — guaranteed alive on all platforms (Unix and Windows). + // PID 1 (init) only works on Unix; on Windows it doesn't exist. + const alivePid = process.ppid; const lockData = { - pid: 1, + pid: alivePid, startedAt: new Date().toISOString(), unitType: "execute-task", unitId: "M001/S01/T02", @@ -152,12 +154,11 @@ test("lock file enables cross-process auto-mode detection", () => { const lock = readCrashLock(dir); assert.ok(lock, "should read the lock"); - assert.equal(lock!.pid, 1); + assert.equal(lock!.pid, alivePid); - // PID 1 is always alive but we don't have permission — isLockProcessAlive - // returns true for EPERM (process exists but we can't signal it) + // Parent PID is always alive — isLockProcessAlive should detect it const alive = isLockProcessAlive(lock!); - assert.equal(alive, true, "PID 1 should be detected as alive (EPERM)"); + assert.equal(alive, true, "parent PID should be detected as alive"); rmSync(dir, { recursive: true, force: true }); });