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

Function scheduleHeadlessForceExit

apps/kimi-code/src/cli/headless-exit.ts:29–39  ·  view source on GitHub ↗
(
  proc: ExitableProcess,
  getExitCode: () => number,
  graceMs: number = HEADLESS_FORCE_EXIT_GRACE_MS,
)

Source from the content-addressed store, hash-verified

27 * Returns the timer handle so callers/tests can `clearTimeout` it.
28 */
29export function scheduleHeadlessForceExit(
30 proc: ExitableProcess,
31 getExitCode: () => number,
32 graceMs: number = HEADLESS_FORCE_EXIT_GRACE_MS,
33): NodeJS.Timeout {
34 const timer = setTimeout(() => {
35 proc.exit(getExitCode());
36 }, graceMs);
37 timer.unref?.();
38 return timer;
39}
40
41/** Resolve once a stream's currently-buffered writes have flushed to its sink. */
42function flushStream(stream: Writable): Promise<void> {

Callers 2

finalizeHeadlessRunFunction · 0.85

Calls 1

exitMethod · 0.65

Tested by

no test coverage detected