MCPcopy Index your code
hub / github.com/garrytan/gstack / isProcessAlive

Function isProcessAlive

design/src/daemon-state.ts:142–152  ·  view source on GitHub ↗
(pid: number)

Source from the content-addressed store, hash-verified

140}
141
142export function isProcessAlive(pid: number): boolean {
143 if (!pid || pid <= 0) return false;
144 try {
145 process.kill(pid, 0);
146 return true;
147 } catch (e: unknown) {
148 // EPERM means it exists, we just can't signal it. ESRCH means it's gone.
149 const code = (e as NodeJS.ErrnoException | undefined)?.code;
150 return code === "EPERM";
151 }
152}
153
154/**
155 * Read the cmdline of a running process. Returns "" on any error.

Callers 6

waitForExitFunction · 0.90
killByPidWithIdentityFunction · 0.90
shutdownDaemonFunction · 0.90
readCmdlineFunction · 0.70
acquireLockFunction · 0.70

Calls

no outgoing calls

Tested by 1

waitForExitFunction · 0.72