fix(tmux): reap pane descendants on destroy#2650
Conversation
There was a problem hiding this comment.
Pull request overview
This PR tightens tmux runtime teardown so that Runtime.Destroy not only kills the tmux session but also reaps pane descendant processes (e.g., backgrounded dev servers) that can otherwise survive tmux kill-session and keep ports/resources allocated.
Changes:
- Capture tmux pane PIDs (session leaders) before teardown and reap those sessions after
kill-sessionvia SIGTERM→grace→SIGKILL. - Add
Options.ReapGrace/ default grace timing for the reap wait. - Add unit tests covering pane PID discovery and destroy-time reaper invocation.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| backend/internal/adapters/runtime/tmux/tmux.go | Adds pane PID discovery and post-destroy session reaping with configurable grace period. |
| backend/internal/adapters/runtime/tmux/commands.go | Adds listPanePIDsArgs command builder for tmux list-panes PID discovery. |
| backend/internal/adapters/runtime/tmux/tmux_test.go | Extends Destroy tests and introduces a reaper seam for safe unit testing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Thanks for contributing to Agent Orchestrator. This PR is being picked up by the current external contributor on-call pair: If someone is already working on this, please continue as usual. You are also welcome to join the AO Discord community. We do daily Discord calls at 10 PM IST, except Saturday. Join the session here: Come by if you want to see what is being built, ask questions, or just hang around with the community. |
There was a problem hiding this comment.
Two small things:
- Bump
defaultReapGracefrom 2s to 5s so background processes get a real chance to release ports before SIGKILL. - The grace wait is paid on every
Destroy(a live session always has panes), even when nothing survived the SIGTERM. Consider apgrep -ssurvivor check to skip the wait + SIGKILL when the sessions are already empty.
Summary
Scope
Validation
Refs #2523