Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(procs): read ps start times in the C locale with collapsed spaces, count a zombie as stopped in the test
Krishna Dobhalc28277c06a98
diff --git a/server/kill-tree-escaped.test.ts b/server/kill-tree-escaped.test.tsindex ac4e39089d..d29144ce04 100644--- a/server/kill-tree-escaped.test.ts+++ b/server/kill-tree-escaped.test.ts@@ -1,3 +1,4 @@+import { execFileSync } from "node:child_process";import { mkdtempSync, readFileSync, rmSync } from "node:fs";import { tmpdir } from "node:os";import { join } from "node:path";@@ -14,7 +15,11 @@ afterEach(() => {dir = grandchild = undefined;});-const alive = (pid: number) => { try { process.kill(pid, 0); return true; } catch { return false; } };+const alive = (pid: number) => {+ try {+ return !execFileSync("ps", ["-o", "stat=", "-p", String(pid)], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim().startsWith("Z");+ } catch { return false; }+};describe.runIf(posix)("execCli timeout", () => {it("stops a SIGTERM-ignoring grandchild that left the process group", async () => {diff --git a/server/procs.ts b/server/procs.tsindex f5e25e81c7..cdc7a4999a 100644--- a/server/procs.ts+++ b/server/procs.ts@@ -70,14 +70,14 @@ function psProcesses(pid?: number): Map<number, LinuxProcess> {const rows = new Map<number, LinuxProcess>();let out: string;try {- out = execFileSync("/bin/ps", [...(pid ? ["-p", String(pid)] : ["-A"]), "-o", "pid=,ppid=,stat=,lstart="], { encoding: "utf8", timeout: 2_000, windowsHide: true });+ out = execFileSync("/bin/ps", [...(pid ? ["-p", String(pid)] : ["-A"]), "-o", "pid=,ppid=,stat=,lstart="], { encoding: "utf8", timeout: 2_000, windowsHide: true, env: { ...process.env, LC_ALL: "C" } });} catch (error) {if (pid && (error as { status?: number }).status === 1) return rows;throw error;}for (const line of out.split(/\r?\n/)) {const match = PS_ROW.exec(line);- if (match) rows.set(Number(match[1]), { pid: Number(match[1]), parent: Number(match[2]), state: match[3][0], start: match[4] });+ if (match) rows.set(Number(match[1]), { pid: Number(match[1]), parent: Number(match[2]), state: match[3][0], start: match[4].replace(/\s+/g, " ") });}return rows;}