GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(opencode): run tui worker shutdown on signal/terminal-exit paths by s2bomb · Pull Request #14238 · anomalyco/opencode

Conversation

@s2bomb

@s2bomb s2bomb commented Feb 19, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Fixes #14237

What does this PR do?

Ensures the TUI command routes process-exit signals through the existing worker
shutdown path, instead of only cleaning up during normal UI exit.

Why this change

thread.ts calls client.call("shutdown") only inside onExit. There are no
handlers for SIGINT, SIGTERM, or SIGHUP, so signal-based exits skip worker
cleanup and child resources can survive.

worker.ts already has the canonical cleanup (Instance.disposeAll() with timeout

  • server.stop(true)). This patch reliably invokes that existing logic from all
    exit paths.

Changes

packages/opencode/src/cli/cmd/tui/thread.ts — one idempotent shutdown wrapper
with a 5s timeout, signal handlers for SIGINT/SIGTERM/SIGHUP, and onExit
routed through the same path. Mirrors signal-driven shutdown already used in other
command entrypoints. No new cleanup semantics introduced.

How did you verify your code works?

Reproduced leak before fix using a deterministic harness (local fake MCP server
under script -q -c), then verified clean exit after fix:

# start TUI under pseudo-terminal host
script -q -c "opencode /tmp/repro-project" /tmp/tui.log &
# send SIGHUP to TUI process
kill -HUP "$(pgrep -f 'opencode /tmp/repro-project')"
# confirm clean exit (exit code 0, no surviving children)

Full test suite: bun test --timeout 30000 in packages/opencode — 1095 pass,
5 skip, 0 fail.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@s2bomb
fix(opencode): run tui worker shutdown on signal/terminal-exit paths
c701f2b
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Feb 19, 2026
@github-actions

github-actions Bot commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the needs:issue label Feb 19, 2026
@github-actions

github-actions Bot commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate PRs Found

Based on the search results, here are related PRs that may be addressing similar issues:

  1. fix(tui): add signal handlers to prevent orphaned processes on terminal close #13848 - fix(tui): add signal handlers to prevent orphaned processes on terminal close

    • Directly related: Adds signal handlers to TUI to prevent orphaned processes, which is very similar to the current PR's goal of handling SIGINT/SIGTERM/SIGHUP
  2. fix(cli): handle SIGHUP to prevent orphaned processes on terminal close #12718 - fix(cli): handle SIGHUP to prevent orphaned processes on terminal close

    • Related: Specifically handles SIGHUP in CLI to prevent orphaned processes, overlaps with signal handling approach in current PR
  3. fix: resolve memory leaks and zombie processes from missing cleanup handlers #13186 - fix: resolve memory leaks and zombie processes from missing cleanup handlers

    • Related: Addresses the same problem of missing cleanup handlers causing zombie processes and resource leaks
  4. fix: prevent orphaned worker process when killed #11603 - fix: prevent orphaned worker process when killed

    • Related: Directly addresses preventing orphaned worker processes

Recommendation: Check PR #13848 first, as it appears to be the most directly related to TUI signal handling. Verify if it already covers the current PR's scope or if this PR addresses remaining gaps.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot removed the needs:issue label Feb 19, 2026
@s2bomb

s2bomb commented Feb 19, 2026

Copy link
Copy Markdown
Author

Closing — this duplicates #13848 (and partially #12718), which I discovered after submission. Will comment there instead.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@s2bomb s2bomb closed this Feb 19, 2026
@s2bomb s2bomb mentioned this pull request Feb 19, 2026
fix(tui): add signal handlers to prevent orphaned processes on terminal close #13848
Closed
@s2bomb
s2bomb deleted the fix/tui-signal-shutdown-leak branch February 19, 2026 05:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

needs:compliance This means the issue will auto-close after 2 hours.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

TUI: signal exits leak child processes

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@s2bomb
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.