MCPcopy
hub / github.com/microsoft/playwright / killProcess

Function killProcess

packages/utils/processLauncher.ts:226–252  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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();

Callers 3

gracefullyCloseFunction · 0.85
killProcessAndCleanupFunction · 0.85
killAndWaitFunction · 0.85

Calls 5

deleteMethod · 0.65
logMethod · 0.65
toStringMethod · 0.65
killMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…