Skip to content

fix(pty): pty session handle leak#15599

Open
kikuchan wants to merge 1 commit intoanomalyco:devfrom
kikuchan:dev
Open

fix(pty): pty session handle leak#15599
kikuchan wants to merge 1 commit intoanomalyco:devfrom
kikuchan:dev

Conversation

@kikuchan
Copy link

@kikuchan kikuchan commented Mar 1, 2026

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?

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

@github-actions
Copy link
Contributor

github-actions bot commented Mar 1, 2026

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

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PTY handle leaks

1 participant