fix: harden process matching during updates - #71
Draft
Dmitriy Vasyura (dmitrivMS) wants to merge 3 commits into
Draft
fix: harden process matching during updates#71Dmitriy Vasyura (dmitrivMS) wants to merge 3 commits into
Dmitriy Vasyura (dmitrivMS) wants to merge 3 commits into
Conversation
Resolve running processes by executable launch name and installation directory before waiting or terminating them. Use cross-bitness-safe path queries, held process handles, and reliable termination checks. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot started reviewing on behalf of
Dmitriy Vasyura (dmitrivMS)
August 6, 2026 07:04
View session
There was a problem hiding this comment.
Pull request overview
This PR hardens Windows process detection and termination in the updater by identifying candidate processes using both launch name and installation directory, using a cross-bitness-safe image path query, and holding process handles to avoid PID-reuse races.
Changes:
- Introduces handle-owned process matching (launch name + install directory) using
QueryFullProcessImageNameWand case-insensitive ordinal comparisons. - Reworks wait/terminate flow to hold process handles across waits and to validate
TerminateProcessfailures + confirm exit via waits. - Expands/updates tests to cover same-name processes at other paths and executable rename scenarios.
Show a summary per file
| File | Description |
|---|---|
| src/process.rs | Refactors process enumeration/matching and termination logic; adds handle ownership, cross-bitness path querying, and expanded process-behavior tests. |
| Cargo.toml | Updates windows-sys feature set to support ordinal string comparison used by the new matching logic. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
Use Unicode-aware Windows path comparison for candidate names and normalize path separators component-wise. Add direct and integration coverage for different installations and the executable replacement flow. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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
QueryFullProcessImageNameWwith limited query access so the 32-bit updater can inspect 64-bit processesTerminateProcessfailures and wait for confirmed process exitCode.exetoold_Code.exerename flowIssue
Fixes microsoft/vscode#76641.
Supersedes #28
This supersedes #28, which ignores
ERROR_ACCESS_DENIEDafter requesting query and termination rights before establishing whether a same-named process belongs to this installation. That approach can still wait on everyCode.exefrom other users for 30 seconds, and it can hide a real termination failure for the target installation.This PR instead queries process identity first with
PROCESS_QUERY_LIMITED_INFORMATION, filters by the executable's launch name and installation directory, and only requests termination rights for verified targets. It also uses a cross-bitness-safe path API and preserves actionable termination errors.The launch-name plus directory match is intentional: Windows updates the image path after
Code.exeis renamed toold_Code.exe, while Toolhelp preserves the original launch name.Related issues
This may also help variants reported in:
\\binfolder being used by another process vscode#60697Validation
cargo check --target i686-pc-windows-msvccargo test --target i686-pc-windows-msvc(23 passed)