Tab title gets reset by Win32 apps in WSL #4832

Closed
opened 2026-01-30 23:57:40 +00:00 by claunia · 6 comments
Owner

Originally created by @heaths on GitHub (Nov 6, 2019).

Environment


Platform ServicePack Version      VersionString
-------- ----------- -------      -------------
 Win32NT             10.0.18363.0 Microsoft Windows NT 10.0.18363.0

+ Ubuntu 16.04.5 LTS via WSL

Steps to reproduce

  1. Create profile for Ubuntu.
  2. Set "tabTitle": "Ubuntu" in config.
  3. Start bash tab. Notice title says "Ubuntu".
  4. Run Win32 console program: sc.exe

Expected behavior

Title still shows "Ubuntu"

Actual behavior

Title shows, before and after running the program, "C:\Windows\system32\sc.exe"

Originally created by @heaths on GitHub (Nov 6, 2019). # Environment ```none Platform ServicePack Version VersionString -------- ----------- ------- ------------- Win32NT 10.0.18363.0 Microsoft Windows NT 10.0.18363.0 + Ubuntu 16.04.5 LTS via WSL ``` # Steps to reproduce 1. Create profile for Ubuntu. 2. Set `"tabTitle": "Ubuntu"` in config. 3. Start bash tab. Notice title says "Ubuntu". 4. Run Win32 console program: sc.exe # Expected behavior Title still shows "Ubuntu" # Actual behavior Title shows, before and after running the program, "C:\Windows\system32\sc.exe"
claunia added the Resolution-Duplicate label 2026-01-30 23:57:40 +00:00
Author
Owner

@DHowett-MSFT commented on GitHub (Nov 6, 2019):

/dup #2645. tabTitle is an initial tab title.

@DHowett-MSFT commented on GitHub (Nov 6, 2019): /dup #2645. `tabTitle` is an _initial_ tab title.
Author
Owner

@ghost commented on GitHub (Nov 6, 2019):

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 (Nov 6, 2019): 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

@heaths commented on GitHub (Nov 6, 2019):

I understand that, but with Win32 consoles the initial tab title is restored. Is this a limitation of wsl?

@heaths commented on GitHub (Nov 6, 2019): I understand that, but with Win32 consoles the initial tab title is restored. Is this a limitation of wsl?
Author
Owner

@DHowett-MSFT commented on GitHub (Nov 6, 2019):

It's not exactly a limitation of WSL, but it is a configuration issue coupled with an issue that plagues all terminals[*]. What's really happening is this:

  1. We launch a console, and set its initial title
  2. We spawn WSL attached to that titled console.
  3. Your shell (through WSL) does not set the title.
  4. You launch sc.exe, which runs in a nested console with an initial title
  5. That nested console's title change propagates to the parent console
  6. sc.exe exits
  7. The shell does not set the title.

[*] There is no affordance in the VT standard for a "title stack" such that an application can push on a title frame and ask that the title be restored afterwards. Titles are write-only, and there's only one of them, so everybody on the same machine needs to work together to make sure the title always makes sense.

Most stock distribution shell configurations include a line that sets or resets the window title after every command; on my installed copy of Ubuntu that happens in $HOME/.bashrc line 69 with a crazy escape sequence inserted into the prompt.

If I suppress that configuration by resetting PS1 to something that doesn't contain the "set title" escape sequence, then run sc.exe, the title remains sc.exe for all eternity. (EDIT: It was unclear - i meant even in stock conhost.)

@DHowett-MSFT commented on GitHub (Nov 6, 2019): It's not exactly a limitation of WSL, but it _is_ a configuration issue coupled with an issue that plagues _all_ terminals[*]. What's really happening is this: 1. We launch a console, and set its initial title 2. We spawn WSL attached to that titled console. 2. Your shell (through WSL) does not set the title. 3. You launch `sc.exe`, which runs in a nested console with an initial title 4. That nested console's title change propagates to the parent console 5. `sc.exe` exits 6. The shell does not set the title. [*] There is no affordance in the VT standard for a "title stack" such that an application can push on a title frame and _ask that the title be restored_ afterwards. Titles are write-only, and there's only one of them, so everybody on the same machine needs to work together to make sure the title always makes sense. Most stock distribution shell configurations include a line that sets or resets the window title after every command; on my installed copy of Ubuntu that happens in `$HOME/.bashrc` line 69 with a crazy escape sequence inserted into the _prompt_. If I suppress that configuration by resetting `PS1` to something that doesn't contain the "set title" escape sequence, then run `sc.exe`, the title remains `sc.exe` for all eternity. (EDIT: It was unclear - i meant even in stock conhost.)
Author
Owner

@DHowett-MSFT commented on GitHub (Nov 6, 2019):

Ah, and here's why it works for CMD. My bit about titles being "write-only" only applies to VT, not the Win32 API. CMD calls GetConsoleTitle and saves/restores that between every command invocation. WSL cannot do that, but because of that limitation shared by all implementors of the common terminal language.

@DHowett-MSFT commented on GitHub (Nov 6, 2019): Ah, and here's why it works for CMD. My bit about titles being "write-only" only applies to VT, not the Win32 API. CMD calls GetConsoleTitle and saves/restores that between every command invocation. WSL cannot do that, but because of that limitation shared by all implementors of the common terminal language.
Author
Owner

@heaths commented on GitHub (Nov 6, 2019):

Thanks for the explanation. Very insightful.

@heaths commented on GitHub (Nov 6, 2019): Thanks for the explanation. Very insightful.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#4832