Skip to content

Conversation

@samuv
Copy link
Collaborator

@samuv samuv commented Oct 23, 2025

Ensures the ToolHive child process always gets cleaned up when the app exits, no matter how it quits. We've added multiple layers of protection to catch every exit scenario:

  • app event handlers (quit, will-quit) - normal user quits
  • Windows session-end handler on BrowserWindow - catches Windows shutdown/restart/logout (where normal quit events don't fire!)
  • process handlers (exit, SIGTERM, SIGINT) - force kills and Docker stops
  • Enhanced stopToolhive() - tries graceful SIGTERM first, then force SIGKILL after 2s timeout
  • spawn options - detached: false + windowsHide: true so Windows job objects auto-kill child processes

I tried multiple way including the upgrade, and it seems consistent

I hope the quit and exit callbacks will cover what we were missing

@samuv samuv self-assigned this Oct 23, 2025
@Copilot Copilot AI review requested due to automatic review settings October 23, 2025 16:31
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the cleanup of the ToolHive child process to ensure it's always terminated when the application exits, regardless of the exit scenario. The changes add multiple layers of protection across different exit paths and improve the graceful shutdown process.

Key changes:

  • Enhanced stopToolhive() with graceful termination (SIGTERM) followed by forced kill (SIGKILL) after 2s timeout
  • Added windowsHide: true spawn option to leverage Windows job objects for automatic child process cleanup
  • Implemented comprehensive exit handlers: quit, session-end (Windows-specific), exit, SIGTERM, and SIGINT

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
main/src/toolhive-manager.ts Enhanced process spawning with Windows job object support and improved stopToolhive() with graceful-then-forced termination
main/src/main.ts Added multiple exit event handlers for comprehensive cleanup coverage across different quit scenarios

@samuv samuv marked this pull request as draft October 23, 2025 16:41
@samuv samuv requested a review from Copilot October 23, 2025 16:49
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

@samuv samuv marked this pull request as ready for review October 23, 2025 17:07
Copy link
Collaborator

@peppescg peppescg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧

@samuv samuv merged commit 87d3843 into main Oct 24, 2025
15 checks passed
@samuv samuv deleted the process-kill branch October 24, 2025 08:40
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.

2 participants