MCPcopy Create free account
hub / github.com/bearlyai/OpenADE / cleanup

Function cleanup

projects/electron/src/modules/code/process.ts:630–668  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

628}
629
630export const cleanup = () => {
631 logger.info("[Process] Cleanup called, killing all active processes")
632
633 for (const [processId, proc] of activeProcesses) {
634 // Cancel cleanup timeouts
635 if (proc.cleanupTimeoutId) {
636 clearTimeout(proc.cleanupTimeoutId)
637 }
638
639 // Kill process group if still running (negative PID kills entire group)
640 if (!proc.completed && proc.process && proc.process.pid) {
641 try {
642 process.kill(-proc.process.pid, "SIGKILL")
643 } catch (err) {
644 // Fallback to killing just the process
645 logger.debug('[Process] Error killing process group during cleanup, falling back to direct kill:', err)
646 try {
647 proc.process.kill("SIGKILL")
648 } catch (err2) {
649 logger.debug('[Process] Error killing process during cleanup:', err2)
650 }
651 }
652 emitLifecycle({ type: "exit", processId, exitCode: null, signal: "SIGKILL" })
653 }
654
655 // Clean up temp script
656 if (proc.tempScriptPath && fs.existsSync(proc.tempScriptPath)) {
657 try {
658 fs.unlinkSync(proc.tempScriptPath)
659 } catch (err) {
660 logger.debug('[Process] Error cleaning up temp script during cleanup:', err)
661 }
662 }
663
664 activeProcesses.delete(processId)
665 }
666
667 logger.info("[Process] Cleanup complete")
668}

Callers 1

killAllRuntimeProcessesFunction · 0.70

Calls 3

emitLifecycleFunction · 0.70
killMethod · 0.65
deleteMethod · 0.65

Tested by

no test coverage detected