From fc67d470f6d6f13d85633743b7035ee2705d5839 Mon Sep 17 00:00:00 2001 From: xdevrobot Date: Tue, 16 Jun 2026 01:50:55 +0500 Subject: [PATCH] docs(runner): add issue #26 references to orphan process prevention comments All four recommendations from issue #26 are already implemented in main: - detached: true removed - spawnedProcesses Set tracks all children - killAllSpawnedProcesses() called in stopAgent() and process.on('exit') - PR_SET_PDEATHSIG helper for Linux This commit adds code comments linking the implementation back to issue #26 for traceability. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/agent/tools/exec/runner.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/agent/tools/exec/runner.ts b/src/agent/tools/exec/runner.ts index 6feff464..7692dc9f 100644 --- a/src/agent/tools/exec/runner.ts +++ b/src/agent/tools/exec/runner.ts @@ -19,12 +19,17 @@ const PDEATHSIG_HELPER = new URL("../../../../bin/prctl-pdeathsig", import.meta. export const MAX_CONCURRENT = 10; let activeCount = 0; -/** Registry of all spawned child processes for cleanup on agent stop. */ +/** + * Registry of all spawned child processes for cleanup on agent stop. + * Prevents orphan/zombie process accumulation when the agent exits + * (graceful shutdown, SIGTERM, or uncaught exception). See issue #26. + */ const spawnedProcesses = new Set>(); /** * Kill all spawned child processes that are still running. - * Called during agent shutdown to prevent zombie process accumulation. + * Called during agent shutdown (stopAgent) and on process.exit + * to prevent orphan processes from surviving the agent (issue #26). */ export function killAllSpawnedProcesses(): void { for (const child of spawnedProcesses) {