Finish Windows compatibility for shutdown process
This commit is contained in:
parent
f409c5f3ec
commit
70da416ca2
1 changed files with 8 additions and 7 deletions
15
app/main.js
15
app/main.js
|
@ -40,7 +40,7 @@ function openItem(fullPath) {
|
||||||
} else if (process.platform == 'linux') {
|
} else if (process.platform == 'linux') {
|
||||||
child = child_process.spawn('xdg-open', [fullPath], subprocOptions);
|
child = child_process.spawn('xdg-open', [fullPath], subprocOptions);
|
||||||
} else if (process.platform == 'win32') {
|
} else if (process.platform == 'win32') {
|
||||||
child = child_process.execSync('start', [fullPath], subprocOptions);
|
child = child_process.spawn(fullPath, [], subprocOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Causes child process reference to be garbage collected, allowing main process to exit
|
// Causes child process reference to be garbage collected, allowing main process to exit
|
||||||
|
@ -48,12 +48,13 @@ function openItem(fullPath) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPidsForProcessName(name) {
|
function getPidsForProcessName(name) {
|
||||||
if (process.platform == 'windows') {
|
if (process.platform == 'win32') {
|
||||||
const tasklistOut = child_process.execSync('tasklist',
|
const tasklistOut = child_process.execSync(`tasklist /fi "Imagename eq ${name}.exe" /nh`, {encoding: 'utf8'});
|
||||||
['/fi', `Imagename eq ${name}.exe`, '/nh'],
|
if (tasklistOut.startsWith('INFO')) {
|
||||||
{encoding: 'utf8'}
|
return [];
|
||||||
).stdout;
|
} else {
|
||||||
return tasklistOut.match(/[^\n]+/g).map((line) => line.split(/\s+/)[1]); // Second column of every non-empty line
|
return tasklistOut.match(/[^\r\n]+/g).map((line) => line.split(/\s+/)[1]); // Second column of every non-empty line
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
const pgrepOut = child_process.spawnSync('pgrep', ['-x', name], {encoding: 'utf8'}).stdout;
|
const pgrepOut = child_process.spawnSync('pgrep', ['-x', name], {encoding: 'utf8'}).stdout;
|
||||||
return pgrepOut.match(/\d+/g);
|
return pgrepOut.match(/\d+/g);
|
||||||
|
|
Loading…
Reference in a new issue