MCPcopy
hub / github.com/garrytan/gstack / isProcessAlive

Function isProcessAlive

browse/src/error-handling.ts:40–58  ·  view source on GitHub ↗
(pid: number)

Source from the content-addressed store, hash-verified

38
39/** Check if a PID is alive. Pure boolean probe — returns false for ALL errors. */
40export function isProcessAlive(pid: number): boolean {
41 if (IS_WINDOWS) {
42 try {
43 const result = Bun.spawnSync(
44 ['tasklist', '/FI', `PID eq ${pid}`, '/NH', '/FO', 'CSV'],
45 { stdout: 'pipe', stderr: 'pipe', timeout: 3000 }
46 );
47 return result.stdout.toString().includes(`"${pid}"`);
48 } catch {
49 return false;
50 }
51 }
52 try {
53 process.kill(pid, 0);
54 return true;
55 } catch {
56 return false;
57 }
58}

Callers 14

gcStaleHermeticDirsFunction · 0.90
readPidStartTimeFunction · 0.90
cleanupXvfbFunction · 0.90
killAgentByRecordFunction · 0.90
killServerFunction · 0.90
cleanupLegacyStateFunction · 0.90
killOrphanChromiumFunction · 0.90
acquireServerLockFunction · 0.90
ensureServerFunction · 0.90
sendCommandFunction · 0.90
mainFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected