Set WorkingDirectory for background mount process to avoid holding caller's CWD handle#2029
Merged
Merged
Conversation
The background mount process (GVFS.Mount.exe) inherits the caller's current working directory, holding a handle that prevents the caller from cleaning up or deleting that directory. This affects tools that launch gvfs clone/mount and need to remove themselves afterward. Set ProcessStartInfo.WorkingDirectory to the program's own directory so the child process does not hold a handle on the caller's CWD. Assisted-by: Claude Opus 4.6 Signed-off-by: Tyrie Vella <tyrielv@gmail.com>
KeithIsSleeping
approved these changes
Jun 17, 2026
YingyHuang
approved these changes
Jun 17, 2026
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.
Problem
When running
gvfs cloneorgvfs mount, the backgroundGVFS.Mount.exeprocess inherits the caller's current working directory. This holds a handle on that directory, preventing the caller from cleaning up or deleting it afterward.This is a problem for bootstrapping tools that launch gvfs and then need to remove themselves.
Fix
Set
ProcessStartInfo.WorkingDirectoryto the directory containing the mount executable (programName). Since the mount process only uses its command-line arguments (which are already absolute paths) to locate the enlistment, it has no dependency on the inherited CWD.Validation
GVFS.Platform.Windowsbuilds cleanlyGVFS.UnitTestsbuilds cleanlymountExecutableLocationis built fromProcessHelper.GetCurrentProcessLocation(), andmountPathcomes fromenlistment.EnlistmentRoot/enlistment.WorkingDirectoryRoot)