MCPcopy Create free account
hub / github.com/code-forge-io/Remix-Forge / kill

Function kill

src/devTools/killProcess.ts:6–22  ·  view source on GitHub ↗
(pid: number)

Source from the content-addressed store, hash-verified

4let isWindows = process.platform === "win32";
5
6export const kill = async (pid: number) => {
7 if (!isAlive(pid)) {return;}
8 if (isWindows) {
9 await execa("taskkill", ["/F", "/PID", pid.toString()]).catch((error: any) => {
10 // taskkill 128 -> the process is already dead
11 if (error.exitCode === 128) {return;}
12 if (/There is no running instance of the task./.test(error.message)) {return;}
13 console.warn(error.message);
14 });
15 return;
16 }
17 await execa("kill", ["-9", pid.toString()]).catch((error: any) => {
18 // process is already dead
19 if (/No such process/.test(error.message)) {return;}
20 console.warn(error.message);
21 });
22};
23
24let isAlive = (pid: number) => {
25 try {

Callers

nothing calls this directly

Calls 1

isAliveFunction · 0.85

Tested by

no test coverage detected