chore(launcher): add more logging to processKill (#6025)

This commit is contained in:
Yury Semikhatsky 2021-03-31 12:17:16 -07:00 committed by GitHub
parent f472c96129
commit 16d98cb48a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -161,15 +161,21 @@ export async function launchProcess(options: LaunchProcessOptions): Promise<Laun
options.log(`[pid=${spawnedProcess.pid}] <kill>`); options.log(`[pid=${spawnedProcess.pid}] <kill>`);
helper.removeEventListeners(listeners); helper.removeEventListeners(listeners);
if (spawnedProcess.pid && !spawnedProcess.killed && !processClosed) { if (spawnedProcess.pid && !spawnedProcess.killed && !processClosed) {
options.log(`[pid=${spawnedProcess.pid}] <will force kill>`);
// Force kill the browser. // Force kill the browser.
try { try {
if (process.platform === 'win32') if (process.platform === 'win32') {
childProcess.execSync(`taskkill /pid ${spawnedProcess.pid} /T /F`, { stdio: 'ignore' }); const stdout = childProcess.execSync(`taskkill /pid ${spawnedProcess.pid} /T /F`);
else options.log(`[pid=${spawnedProcess.pid}] taskkill output: ${stdout.toString()}`);
} else {
process.kill(-spawnedProcess.pid, 'SIGKILL'); process.kill(-spawnedProcess.pid, 'SIGKILL');
}
} catch (e) { } catch (e) {
options.log(`[pid=${spawnedProcess.pid}] exception while trying to kill process: ${e}`);
// the process might have already stopped // the process might have already stopped
} }
} else {
options.log(`[pid=${spawnedProcess.pid}] <skipped force kill spawnedProcess.killed=${spawnedProcess.killed} processClosed=${processClosed}>`);
} }
cleanup(); cleanup();
} }