Skip to content

fix(tui): close slash_worker in _finalize_session to prevent zombie processes #38095 - #38218

Closed
kyssta-exe wants to merge 1 commit into
NousResearch:mainfrom
kyssta-exe:auto-fix/issue-38095-v2
Closed

fix(tui): close slash_worker in _finalize_session to prevent zombie processes #38095#38218
kyssta-exe wants to merge 1 commit into
NousResearch:mainfrom
kyssta-exe:auto-fix/issue-38095-v2

Conversation

@kyssta-exe

Copy link
Copy Markdown
Contributor

Summary

When a TUI session is closed, was not cleaning up the subprocess. This left orphaned processes accumulating each time the TUI was opened and closed while the dashboard remained running.

Problem

handles memory commits, notification stops, and DB session ending, but does not close the subprocess. Code paths that call without separately handling worker cleanup (e.g., TUI close without explicit RPC) leave zombie processes.

Fix

Add slash_worker cleanup to so any code path that calls it properly terminates the worker subprocess. The method is idempotent (checks before terminating), so double-close from is safe.

Testing

  • Verified is idempotent
  • Follows existing error-handling pattern (best-effort try/except)
  • No lint errors introduced

Fixes #38095

…rocesses

When a TUI session is closed, _finalize_session() was not cleaning up
the _SlashWorker subprocess. This left orphaned processes accumulating
each time the TUI was opened/closed while the dashboard remained running.

_add slash_worker cleanup to _finalize_session() so any code path that
calls it (session close, shutdown, error recovery) properly terminates
the worker subprocess.

Fixes NousResearch#38095
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/tui Terminal UI (ui-tui/ + tui_gateway/) duplicate This issue or pull request already exists labels Jun 3, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #38114 — both fix #38095 by closing session['slash_worker'] in _finalize_session() (tui_gateway/server.py). #38114 additionally hardens _SlashWorker.close() and nulls the ref in _restart_slash_worker, plus adds 5 tests (but bundles an unrelated version bump). Same zombie-leak family as #21370/#27073/#22863. Flagging for de-dup.

@teknium1

teknium1 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Superseded by #42132 (merged), which closes the slash_worker subprocess leak via two guards: process-group kill on PTY teardown + a cross-platform parent-death watchdog in the worker. Closing as resolved — thanks for tackling this; the merged fix salvaged the process-group-kill and watchdog approaches with contributor authorship preserved.

@teknium1 teknium1 closed this Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tui Terminal UI (ui-tui/ + tui_gateway/) duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: TUI slash worker subprocesses leak after session close, accumulating zombie processes

3 participants