From e0f1388ad6daee902e57019db0454cd9192a73f1 Mon Sep 17 00:00:00 2001 From: luvs01 <27862058+luvs01@users.noreply.github.com> Date: Mon, 10 Aug 2026 00:04:59 +0900 Subject: [PATCH] fix(codex): pin Darwin process utility path --- src/codex/app-server-processes.ts | 8 ++++---- tests/codex-app-server-processes.test.ts | 12 ++++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/codex/app-server-processes.ts b/src/codex/app-server-processes.ts index d0d9963a88..85fa170336 100644 --- a/src/codex/app-server-processes.ts +++ b/src/codex/app-server-processes.ts @@ -272,12 +272,12 @@ function listDarwinSnapshots(uid: number | undefined): ProcessSnapshot[] { // Top-level exec failure propagates: callers decide their own safe default // (restart flow → treat as none; staleness check → unknown, never "fresh"). const output = uid !== undefined - ? execFileSync("ps", ["-u", String(uid), "-o", "pid=,command="], { + ? execFileSync("/bin/ps", ["-u", String(uid), "-o", "pid=,command="], { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"], timeout: 5_000, }) - : execFileSync("ps", ["-axo", "pid=,uid=,command="], { + : execFileSync("/bin/ps", ["-axo", "pid=,uid=,command="], { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"], timeout: 5_000, @@ -444,7 +444,7 @@ function readLinuxProcStartMs(pid: number): number | null { /** `ps` lstart → epoch ms, or null (macOS). */ function readDarwinProcStartMs(pid: number): number | null { try { - const out = execFileSync("ps", ["-o", "lstart=", "-p", String(pid)], { + const out = execFileSync("/bin/ps", ["-o", "lstart=", "-p", String(pid)], { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"], timeout: 4_000, @@ -493,7 +493,7 @@ export function readProcessStartMsBatch( if (pids.length === 0) return out; if (platform === "darwin") { try { - const stdout = execFileSync("ps", ["-o", "pid=,lstart=", "-p", pids.join(",")], { + const stdout = execFileSync("/bin/ps", ["-o", "pid=,lstart=", "-p", pids.join(",")], { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"], timeout: 3_000, diff --git a/tests/codex-app-server-processes.test.ts b/tests/codex-app-server-processes.test.ts index c1b421bd79..55d6f5617e 100644 --- a/tests/codex-app-server-processes.test.ts +++ b/tests/codex-app-server-processes.test.ts @@ -429,6 +429,18 @@ describe("CLI /api sync wiring for stale app-servers (#476)", () => { }); }); +describe("process utility invocation source guards", () => { + const processSource = readFileSync( + join(import.meta.dir, "..", "src", "codex", "app-server-processes.ts"), + "utf8", + ); + + test("pins every Darwin ps invocation to the system binary", () => { + expect(processSource.match(/execFileSync\(\s*["']\/bin\/ps["']/g) ?? []).toHaveLength(4); + expect(processSource).not.toMatch(/execFileSync\(\s*["']ps["']/); + }); +}); + describe("Windows Win32_Process owner enumeration (#476)", () => { const processSource = readFileSync( join(import.meta.dir, "..", "src", "codex", "app-server-processes.ts"),