OpenConsole/WindowsTerminal keep handles on directory after closing tab, when terminal is opened through context menu. #16130

Closed
opened 2026-01-31 04:58:21 +00:00 by claunia · 3 comments
Owner

Originally created by @JornVernee on GitHub (Dec 15, 2021).

Windows Terminal version

1.11.2921.0

Windows build number

10.0.19043.0

Other Software

No response

Steps to reproduce

  1. Create a test directory, e.g. test
  2. Open the directory in Windows explorer,
  3. Use the right-click context menu to "Open in Windows terminal". This should open a powershell instance with the working directory set to the test directory. (Note that opening the terminal somewhere else, and cd'ing to the test directory will not create the problematic file handles).
  4. Open a new Windows Terminal tab (e.g. I'm using Ubuntu to test). Make sure that this shell is not using the test directory as a working directory.
  5. Close the original (powershell) tab that has the test directory as working directory.
  6. Try to delete the test directory. This should fail because the directory is still in use by another process.

At this point, you could use e.g. Resource Monitor to see that OpenConsole.exe and WindowsTerminal.exe still have open handles on the test directory.
image

The workaround for this is to close the Windows terminal instance, which will release the handles.

Expected Behavior

After closing the original tab in Windows terminal, it should be possible to delete the test directory.

This feels like a resource leak, since I am no longer using the test directory through Windows Terminal, and (AFAIK) there is nothing I can do in Windows Terminal to release those file handles.

Actual Behavior

Deleting the test directory failes, because there are still open handles on it.

Originally created by @JornVernee on GitHub (Dec 15, 2021). ### Windows Terminal version 1.11.2921.0 ### Windows build number 10.0.19043.0 ### Other Software _No response_ ### Steps to reproduce 1. Create a test directory, e.g. `test` 2. Open the directory in Windows `explorer`, 3. Use the right-click context menu to "Open in Windows terminal". This should open a powershell instance with the working directory set to the `test` directory. (Note that opening the terminal somewhere else, and `cd`'ing to the `test` directory will not create the problematic file handles). 4. Open a new Windows Terminal tab (e.g. I'm using Ubuntu to test). Make sure that this shell is not using the `test` directory as a working directory. 5. Close the original (powershell) tab that has the `test` directory as working directory. 6. Try to delete the `test` directory. This should fail because the directory is still in use by another process. At this point, you could use e.g. Resource Monitor to see that OpenConsole.exe and WindowsTerminal.exe still have open handles on the test directory. ![image](https://user-images.githubusercontent.com/5962029/146224510-d96d0039-0eaa-4469-a5b4-b3fa2611465f.png) The workaround for this is to close the Windows terminal instance, which will release the handles. ### Expected Behavior After closing the original tab in Windows terminal, it should be possible to delete the `test` directory. This feels like a resource leak, since I am no longer using the `test` directory through Windows Terminal, and (AFAIK) there is nothing I can do in Windows Terminal to release those file handles. ### Actual Behavior Deleting the `test` directory failes, because there are still open handles on it.
claunia added the Resolution-Duplicate label 2026-01-31 04:58:21 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Dec 15, 2021):

Thanks for the suggestion! This is actually already being tracked by another issue on our repo - please refer to #5506 for more discussion.

/dup #5506

@zadjii-msft commented on GitHub (Dec 15, 2021): Thanks for the suggestion! This is actually already being tracked by another issue on our repo - please refer to #5506 for more discussion. /dup #5506
Author
Owner

@ghost commented on GitHub (Dec 15, 2021):

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@ghost commented on GitHub (Dec 15, 2021): Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!
Author
Owner

@JornVernee commented on GitHub (Dec 15, 2021):

Thanks! I couldn't find it when searching.

@JornVernee commented on GitHub (Dec 15, 2021): Thanks! I couldn't find it when searching.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#16130