MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / pidAlive

Function pidAlive

packages/server/src/lock.ts:114–126  ·  view source on GitHub ↗

`process.kill(pid, 0)` probe — true if the pid exists, false on ESRCH.

(pid: number)

Source from the content-addressed store, hash-verified

112
113/** `process.kill(pid, 0)` probe — true if the pid exists, false on ESRCH. */
114function pidAlive(pid: number): boolean {
115 try {
116 process.kill(pid, 0);
117 return true;
118 } catch (err) {
119 const code = (err as NodeJS.ErrnoException).code;
120 if (code === 'ESRCH') return false;
121 // EPERM = process exists but we can't signal it (different user). Treat as alive.
122 if (code === 'EPERM') return true;
123 // Anything else: be safe, assume alive so we don't clobber.
124 return true;
125 }
126}
127
128/** Read + JSON.parse the lock file; returns undefined on any error so callers can fall through. */
129function readLockContents(path: string): LockContents | undefined {

Callers 2

getLiveLockFunction · 0.70
acquireLockFunction · 0.70

Calls 1

killMethod · 0.65

Tested by

no test coverage detected