()
| 224 | |
| 225 | // This method has to be sync to be used in the 'exit' event handler. |
| 226 | function killProcess() { |
| 227 | gracefullyCloseSet.delete(gracefullyClose); |
| 228 | killSet.delete(killProcessAndCleanup); |
| 229 | removeProcessHandlersIfNeeded(); |
| 230 | options.log(`[pid=${spawnedProcess.pid}] <kill>`); |
| 231 | if (spawnedProcess.pid && !spawnedProcess.killed && !processClosed) { |
| 232 | options.log(`[pid=${spawnedProcess.pid}] <will force kill>`); |
| 233 | // Force kill the browser. |
| 234 | try { |
| 235 | if (process.platform === 'win32') { |
| 236 | const taskkillProcess = childProcess.spawnSync(`taskkill /pid ${spawnedProcess.pid} /T /F`, { shell: true }); |
| 237 | const [stdout, stderr] = [taskkillProcess.stdout.toString(), taskkillProcess.stderr.toString()]; |
| 238 | if (stdout) |
| 239 | options.log(`[pid=${spawnedProcess.pid}] taskkill stdout: ${stdout}`); |
| 240 | if (stderr) |
| 241 | options.log(`[pid=${spawnedProcess.pid}] taskkill stderr: ${stderr}`); |
| 242 | } else { |
| 243 | process.kill(-spawnedProcess.pid, 'SIGKILL'); |
| 244 | } |
| 245 | } catch (e) { |
| 246 | options.log(`[pid=${spawnedProcess.pid}] exception while trying to kill process: ${e}`); |
| 247 | // the process might have already stopped |
| 248 | } |
| 249 | } else { |
| 250 | options.log(`[pid=${spawnedProcess.pid}] <skipped force kill spawnedProcess.killed=${spawnedProcess.killed} processClosed=${processClosed}>`); |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | function killProcessAndCleanup() { |
| 255 | killProcess(); |
no test coverage detected
searching dependent graphs…