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

Function killProc

packages/agent-core/src/tools/support/run-rg.ts:115–143  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

113 let killed = false;
114
115 const killProc = async (): Promise<void> => {
116 if (killed) return;
117 killed = true;
118 try {
119 await proc.kill('SIGTERM');
120 } catch {
121 /* process already gone */
122 }
123 const exited = proc
124 .wait()
125 .then(() => true)
126 .catch(() => true);
127 const raced = await Promise.race([
128 exited,
129 new Promise<false>((resolve) => {
130 setTimeout(() => {
131 resolve(false);
132 }, SIGTERM_GRACE_MS);
133 }),
134 ]);
135 if (!raced && proc.exitCode === null) {
136 try {
137 await proc.kill('SIGKILL');
138 } catch {
139 /* ignore */
140 }
141 }
142 await disposeProcess(proc);
143 };
144
145 const onAbort = (): void => {
146 aborted = true;

Callers 2

onAbortFunction · 0.85
runRipgrepOnceFunction · 0.85

Calls 4

disposeProcessFunction · 0.70
killMethod · 0.65
waitMethod · 0.65
resolveFunction · 0.50

Tested by

no test coverage detected