MCPcopy Create free account
hub / github.com/MCSManager/MCSManager / killProcess

Function killProcess

common/src/process_tools.ts:123–141  ·  view source on GitHub ↗
(
  pid: string | number,
  process: { kill(signal?: any): any },
  signal?: any
)

Source from the content-addressed store, hash-verified

121}
122
123export function killProcess(
124 pid: string | number,
125 process: { kill(signal?: any): any },
126 signal?: any
127) {
128 try {
129 if (os.platform() === "win32") {
130 execSync(`taskkill /PID ${pid} /T /F`);
131 return true;
132 }
133 if (os.platform() === "linux") {
134 killLinuxProcessTree(pid);
135 return true;
136 }
137 } catch (err) {
138 return signal ? process.kill(signal) : process.kill("SIGKILL");
139 }
140 return signal ? process.kill(signal) : process.kill("SIGKILL");
141}
142
143function killLinuxProcessTree(pid: string | number) {
144 const targetPid = Number(pid);

Callers 5

startMethod · 0.85
killMethod · 0.85
onStopMethod · 0.85
killMethod · 0.85
killMethod · 0.85

Calls 2

killLinuxProcessTreeFunction · 0.85
killMethod · 0.45

Tested by

no test coverage detected