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

Function waitForExit

apps/kimi-code/src/cli/sub/server/kill.ts:99–110  ·  view source on GitHub ↗
(
  pid: number,
  timeoutMs: number,
  deps: Pick<KillCommandDeps, 'pidAlive' | 'sleep' | 'now'>,
)

Source from the content-addressed store, hash-verified

97}
98
99async function waitForExit(
100 pid: number,
101 timeoutMs: number,
102 deps: Pick<KillCommandDeps, 'pidAlive' | 'sleep' | 'now'>,
103): Promise<boolean> {
104 const deadline = deps.now() + timeoutMs;
105 do {
106 if (!deps.pidAlive(pid)) return true;
107 await deps.sleep(POLL_INTERVAL_MS);
108 } while (deps.now() < deadline);
109 return !deps.pidAlive(pid);
110}
111
112/** `process.kill(pid, 0)` probe — true if the pid exists, false on ESRCH. */
113export function pidAlive(pid: number): boolean {

Callers 1

handleKillCommandFunction · 0.85

Calls 3

pidAliveMethod · 0.80
sleepMethod · 0.80
nowMethod · 0.65

Tested by

no test coverage detected