MCPcopy Create free account
hub / github.com/Kong/insomnia / killProcessTree

Function killProcessTree

packages/insomnia/src/sync/git/providers/native.ts:151–174  ·  view source on GitHub ↗
(proc: ChildProcess)

Source from the content-addressed store, hash-verified

149 * them (and their sign-in windows) behind.
150 */
151const killProcessTree = (proc: ChildProcess) => {
152 const { pid } = proc;
153 if (!pid) {
154 return;
155 }
156
157 if (process.platform === 'win32') {
158 spawn('taskkill', ['/pid', String(pid), '/T', '/F'], { stdio: 'ignore', windowsHide: true }).on('error', err => {
159 console.warn('[NativeProvider] Failed to stop git credential process:', err.message);
160 });
161 return;
162 }
163
164 // POSIX: the process was spawned detached, i.e. as the leader of its own process group.
165 const killGroup = (signal: NodeJS.Signals) => {
166 try {
167 process.kill(-pid, signal);
168 } catch {
169 // The group is already gone.
170 }
171 };
172 killGroup('SIGTERM');
173 setTimeout(() => killGroup('SIGKILL'), KILL_GRACE_MS).unref?.();
174};
175
176/**
177 * Run `git credential <action>` with the given attributes on stdin. The result

Callers 1

runGitCredentialFunction · 0.70

Calls 2

killGroupFunction · 0.85
onMethod · 0.80

Tested by

no test coverage detected