fix(background-agent): prevent zombie processes by aborting sessions on shutdown (#1240) (#1243)

- BackgroundManager.shutdown() now aborts all running child sessions via
  client.session.abort() before clearing state, preventing orphaned
  opencode processes when parent exits
- Add onShutdown callback to BackgroundManager constructor, used to
  trigger TmuxSessionManager.cleanup() on process exit signals
- Interactive bash session hook now aborts tracked subagent opencode
  sessions when killing tmux sessions (defense-in-depth)
- Add 4 tests verifying shutdown abort behavior and callback invocation

Closes #1240
This commit is contained in:
YeonGyu-Kim
2026-01-29 18:29:47 +09:00
committed by GitHub
parent 6d50fbe563
commit b4973954e3
4 changed files with 194 additions and 2 deletions
+5
View File
@@ -264,6 +264,11 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
});
log("[index] onSubagentSessionCreated callback completed");
},
onShutdown: () => {
tmuxSessionManager.cleanup().catch((error) => {
log("[index] tmux cleanup error during shutdown:", error)
})
},
});
const atlasHook = isHookEnabled("atlas")