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(pty): pty session handle leak by kikuchan · Pull Request #15599 · anomalyco/opencode

Conversation

@kikuchan

@kikuchan kikuchan commented Mar 1, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #15592

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Ensure to call session.process.kill() on ptyProcess.onExit to clean up PTY sessions properly.

How did you verify your code works?

(edited) Added an automated test for the issue.

static analysis, and dynamic analysis by hands with `console.log`.

Before the patch:
onExit() -> publish Exited event -> state().delete(id) -> cannot remove() anymore.

After the patch:
onExit() -> publish Exited event -> session.process.kill() -> publish Delete event

Note:
onExit() and remove() are called twice at most, so I have to move state().delete(id) to above and add session.info.status === 'exited' check.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Sorry, something went wrong.

Uh oh!

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

Mte90 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@github-actions

github-actions Bot commented Mar 1, 2026

Copy link
Copy Markdown
Contributor

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

Based on my search, I found one potentially related PR:

  • PR fix: resolve memory leaks and zombie processes from missing cleanup handlers #13186: fix: resolve memory leaks and zombie processes from missing cleanup handlers
    • This PR addresses similar concerns around process cleanup and preventing zombie processes, which relates to the PTY session cleanup issue in PR fix(pty): pty session handle leak #15599.

The other results (PRs #12718 and #12877) are older signal handler PRs that address orphaned processes but appear to be different approaches.

PR #13186 is the most relevant as it deals with the same core issue: ensuring proper cleanup of processes to prevent memory leaks and zombie processes.

All reactions

Sorry, something went wrong.

Uh oh!

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

@kikuchan
kikuchan force-pushed the dev branch 3 times, most recently from 0e24aa1 to c128e50 Compare March 6, 2026 09:53
kikuchan added 2 commits March 6, 2026 23:08
@kikuchan
test(pty): for session handle leak
1999d72
@kikuchan
fix(pty): pty session handle leak
f08af7d
@kikuchan
kikuchan force-pushed the dev branch from c128e50 to f08af7d Compare March 6, 2026 14:08
Hona
Hona approved these changes Mar 7, 2026
View reviewed changes
@Hona
Hona merged commit b2c2478 into anomalyco:dev Mar 7, 2026
9 checks passed

Uh oh!

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

demostanis pushed a commit to demostanis/opencode that referenced this pull request Mar 20, 2026
@kikuchan @demostanis
fix(pty): pty session handle leak (anomalyco#15599)
332fd28
@coleleavitt coleleavitt mentioned this pull request Apr 21, 2026
fix/memory 20695 coleleavitt/opencode#5
Merged
@liu5269 liu5269 mentioned this pull request Apr 26, 2026
[Windows Desktop] New Terminal always fails with PTY spawn failed (across multiple versions) #24463
Closed
Rwanbt pushed a commit to Rwanbt/unifia that referenced this pull request May 5, 2026
@kikuchan
fix(pty): pty session handle leak (anomalyco#15599)
2dba81c
AIALRA-0 pushed a commit to AIALRA-0/opencode-turn-engine that referenced this pull request Jun 10, 2026
@kikuchan
fix(pty): pty session handle leak (anomalyco#15599)
3ded2bc
Rwanbt pushed a commit to Rwanbt/unifia that referenced this pull request Jun 14, 2026
@kikuchan
fix(pty): pty session handle leak (anomalyco#15599)
ee7d93e
MarsQiu007 referenced this pull request in MarsQiu007/openNovel Jul 31, 2026
@kikuchan
fix(pty): pty session handle leak (#15599)
0cea955
meSingh pushed a commit to meSingh/opencode that referenced this pull request Sep 6, 2026
@kikuchan
fix(pty): pty session handle leak (anomalyco#15599)
0c9c067
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@Hona Hona Hona approved these changes

Uh oh!

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

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

PTY handle leaks

Uh oh!

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

2 participants

@kikuchan @Hona
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.