Fix repeated terminal launches when reopening GodotHub with Godot running - #162
Merged
Conversation
Fix repeated terminal open/close behavior when GodotHub is restarted while a Godot project is still running. Root cause: - After GodotHub exited, stale Godot sessions were recovered using platform-specific tracking logic. - Unix used path polling, while Windows mixed PID checks and external process discovery. - Reopening GodotHub while Godot was still running could cause the monitoring loop to repeatedly launch process-query commands. - On Windows, those helper processes could create visible terminal windows, resulting in a loop of terminal startup and immediate close. Changes: - Add a dedicated cross-platform process module. - Use one-time process discovery during stale-session recovery. - Track recovered Godot processes by PID on Windows and Unix. - Use Windows OpenProcess/GetExitCodeProcess and Unix kill(pid, 0) for liveness checks. - Revalidate the PID and project path once when the PID appears to exit. - Verify process identity before terminating a recovered process. - Remove repeated ps/PowerShell/WMIC calls from the normal monitoring loop. - Remove duplicated process APIs from terminal.rs. - Move process parser tests out of projects.rs. - Organize tests into common, windows, and unix directories. - Add Windows-only windows-sys dependencies.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes a Windows issue where reopening GodotHub while a Godot project was
still running could cause a terminal window to repeatedly open and close.
The same session-tracking behavior is now unified across Windows and Unix
platforms, including Linux and macOS.
Problem
The issue could be reproduced as follows:
Close application on project open, or close GodotHub manually.Under the affected implementation, GodotHub recovered the stale project session
using platform-specific process detection. The monitoring path could repeatedly
launch external process-query commands such as PowerShell, WMIC, or
ps.On Windows, these helper-process launches could become visible as terminal
windows, producing this loop:
Closing the Godot process stopped the loop because the stale-session monitor no
longer had an active process to track.
Root Cause
Process discovery and process monitoring were mixed together:
Solution
This PR introduces a dedicated cross-platform process module.
Process tracking
OpenProcessandGetExitCodeProcess.kill(pid, 0).against the stored Godot project path.
Test organization
Process tests were moved out of projects.rs and organized as:
Expected Result
terminal open/close loop.
WMIC, or
ps.behavior remains unchanged.
Verification
Passed locally:
The Windows-specific tests run on the current Windows environment. The Unix
tests are selected with
cfg(unix)and should be run on Linux/macOS CI ornative development environments.
Files Changed