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

Function tryKillProcess

packages/agent-core/src/session/hooks/runner.ts:210–229  ·  view source on GitHub ↗
(child: ChildProcessWithoutNullStreams, signal: NodeJS.Signals)

Source from the content-addressed store, hash-verified

208}
209
210function tryKillProcess(child: ChildProcessWithoutNullStreams, signal: NodeJS.Signals): void {
211 if (process.platform === 'win32') {
212 // On Windows, `ChildProcess.kill()` only signals the shell spawned by
213 // `shell: true`, leaving grandchildren (the actual hook command) alive
214 // and holding the cwd. `taskkill /T` terminates the whole process tree.
215 killProcessTreeWindows(child, signal === 'SIGKILL');
216 return;
217 }
218 try {
219 if (child.pid !== undefined) {
220 process.kill(-child.pid, signal);
221 } else {
222 child.kill(signal);
223 }
224 } catch {
225 try {
226 child.kill(signal);
227 } catch {}
228 }
229}
230
231function killProcessTreeWindows(child: ChildProcessWithoutNullStreams, force: boolean): void {
232 if (child.pid === undefined) return;

Callers 1

killProcessFunction · 0.85

Calls 2

killProcessTreeWindowsFunction · 0.85
killMethod · 0.65

Tested by

no test coverage detected