MCPcopy
hub / github.com/google-gemini/gemini-cli / cleanup

Function cleanup

scripts/telemetry_utils.js:410–446  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

408) {
409 let cleanedUp = false;
410 const cleanup = () => {
411 if (cleanedUp) return;
412 cleanedUp = true;
413
414 console.log('\n👋 Shutting down...');
415
416 manageTelemetrySettings(false, null, null, originalSandboxSetting);
417
418 const processes = getProcesses ? getProcesses() : [];
419 processes.forEach((proc) => {
420 if (proc && proc.pid) {
421 const name = path.basename(proc.spawnfile);
422 try {
423 console.log(`🛑 Stopping ${name} (PID: ${proc.pid})...`);
424 process.kill(proc.pid, 'SIGTERM');
425 console.log(`✅ ${name} stopped.`);
426 } catch (e) {
427 if (e.code !== 'ESRCH') {
428 console.error(`Error stopping ${name}: ${e.message}`);
429 }
430 }
431 }
432 });
433
434 const logFileDescriptors = getLogFileDescriptors
435 ? getLogFileDescriptors()
436 : [];
437 logFileDescriptors.forEach((fd) => {
438 if (fd) {
439 try {
440 fs.closeSync(fd);
441 } catch {
442 /* no-op */
443 }
444 }
445 });
446 };
447
448 process.on('exit', cleanup);
449 process.on('SIGINT', () => process.exit(0));

Calls 4

manageTelemetrySettingsFunction · 0.85
logMethod · 0.65
killMethod · 0.65
errorMethod · 0.65

Tested by

no test coverage detected