aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src/utils')
-rw-r--r--editors/code/src/utils/processes.ts68
1 files changed, 36 insertions, 32 deletions
diff --git a/editors/code/src/utils/processes.ts b/editors/code/src/utils/processes.ts
index 09fdf6e24..d4c2c8778 100644
--- a/editors/code/src/utils/processes.ts
+++ b/editors/code/src/utils/processes.ts
@@ -5,36 +5,40 @@ import ChildProcess = cp.ChildProcess;
5 5
6import { join } from 'path'; 6import { join } from 'path';
7 7
8const isWindows = (process.platform === 'win32'); 8const isWindows = process.platform === 'win32';
9const isMacintosh = (process.platform === 'darwin'); 9const isMacintosh = process.platform === 'darwin';
10const isLinux = (process.platform === 'linux'); 10const isLinux = process.platform === 'linux';
11export function terminate(process: ChildProcess, cwd?: string): boolean { 11export function terminate(process: ChildProcess, cwd?: string): boolean {
12 if (isWindows) { 12 if (isWindows) {
13 try { 13 try {
14 // This we run in Atom execFileSync is available. 14 // This we run in Atom execFileSync is available.
15 // Ignore stderr since this is otherwise piped to parent.stderr 15 // Ignore stderr since this is otherwise piped to parent.stderr
16 // which might be already closed. 16 // which might be already closed.
17 const options: any = { 17 const options: any = {
18 stdio: ['pipe', 'pipe', 'ignore'] 18 stdio: ['pipe', 'pipe', 'ignore']
19 }; 19 };
20 if (cwd) { 20 if (cwd) {
21 options.cwd = cwd 21 options.cwd = cwd;
22 } 22 }
23 (cp).execFileSync('taskkill', ['/T', '/F', '/PID', process.pid.toString()], options); 23 cp.execFileSync(
24 return true; 24 'taskkill',
25 } catch (err) { 25 ['/T', '/F', '/PID', process.pid.toString()],
26 return false; 26 options
27 } 27 );
28 } else if (isLinux || isMacintosh) { 28 return true;
29 try { 29 } catch (err) {
30 const cmd = join(__dirname, 'terminateProcess.sh'); 30 return false;
31 const result = cp.spawnSync(cmd, [process.pid.toString()]); 31 }
32 return result.error ? false : true; 32 } else if (isLinux || isMacintosh) {
33 } catch (err) { 33 try {
34 return false; 34 const cmd = join(__dirname, 'terminateProcess.sh');
35 } 35 const result = cp.spawnSync(cmd, [process.pid.toString()]);
36 } else { 36 return result.error ? false : true;
37 process.kill('SIGKILL'); 37 } catch (err) {
38 return true; 38 return false;
39 } 39 }
40} \ No newline at end of file 40 } else {
41 process.kill('SIGKILL');
42 return true;
43 }
44}