MCPcopy Index your code
hub / github.com/microsoft/vscode-languageserver-node / terminate

Function terminate

client/src/utils/processes.ts:15–44  ·  view source on GitHub ↗
(process: ChildProcess, cwd?: string)

Source from the content-addressed store, hash-verified

13const isMacintosh = (process.platform === 'darwin');
14const isLinux = (process.platform === 'linux');
15export function terminate(process: ChildProcess, cwd?: string): boolean {
16 if (isWindows) {
17 try {
18 // This we run in Atom execFileSync is available.
19 // Ignore stderr since this is otherwise piped to parent.stderr
20 // which might be already closed.
21 let options: any = {
22 stdio: ['pipe', 'pipe', 'ignore']
23 };
24 if (cwd) {
25 options.cwd = cwd
26 }
27 (<any>cp).execFileSync('taskkill', ['/T', '/F', '/PID', process.pid.toString()], options);
28 return true;
29 } catch (err) {
30 return false;
31 }
32 } else if (isLinux || isMacintosh) {
33 try {
34 var cmd = join(__dirname, 'terminateProcess.sh');
35 var result = (<any>cp).spawnSync(cmd, [process.pid.toString()]);
36 return result.error ? false : true;
37 } catch (err) {
38 return false;
39 }
40 } else {
41 process.kill('SIGKILL');
42 return true;
43 }
44}

Callers 1

checkProcessDiedMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected