fix(Launcher): killing a process can throw (#2102)

In case chrome process was terminated manually, killing the process
might throw 'no process with such pid' exception.
This commit is contained in:
Georgii Dolzhykov 2018-03-16 02:40:24 +02:00 committed by Andrey Lushnikov
parent ec3025fe84
commit 4e1f2e2eb2

View File

@ -178,10 +178,14 @@ class Launcher {
helper.removeEventListeners(listeners); helper.removeEventListeners(listeners);
if (chromeProcess.pid && !chromeProcess.killed && !chromeClosed) { if (chromeProcess.pid && !chromeProcess.killed && !chromeClosed) {
// Force kill chrome. // Force kill chrome.
if (process.platform === 'win32') try {
childProcess.execSync(`taskkill /pid ${chromeProcess.pid} /T /F`); if (process.platform === 'win32')
else childProcess.execSync(`taskkill /pid ${chromeProcess.pid} /T /F`);
process.kill(-chromeProcess.pid, 'SIGKILL'); else
process.kill(-chromeProcess.pid, 'SIGKILL');
} catch (e) {
// the process might have already stopped
}
} }
// Attempt to remove temporary profile directory to avoid littering. // Attempt to remove temporary profile directory to avoid littering.
try { try {