No terminal resize notification for unix/linux programs #21842

Closed
opened 2026-01-31 07:56:15 +00:00 by claunia · 6 comments
Owner

Originally created by @ant5 on GitHub (Jun 7, 2024).

Windows Terminal version

1.21.1272.0

Windows build number

10.0.19045.4291

Other Software

QEMU 9.0

Steps to reproduce

Run QEMU with unix-like guest OS which serial port connected to console (WindowsTerminal). Resize Terminal window.

Expected Behavior

As I understand WindowTerminal must emit control sequence to notify of width/height change.
Here is a screenshot of similiar system in another terminal that resize correctly:

image

Actual Behavior

Window is reisized but internal structure get corrupt. Notice the cursor moved outside it normal position. I think this is a result of adapation maked by WindowsTerminal itself.

image

But most unix terminal programs can handle terminal resize notification. It will be very nice to have it for seamless integration.

Originally created by @ant5 on GitHub (Jun 7, 2024). ### Windows Terminal version 1.21.1272.0 ### Windows build number 10.0.19045.4291 ### Other Software QEMU 9.0 ### Steps to reproduce Run QEMU with unix-like guest OS which serial port connected to console (WindowsTerminal). Resize Terminal window. ### Expected Behavior As I understand WindowTerminal must emit control sequence to notify of width/height change. Here is a screenshot of similiar system in another terminal that resize correctly: ![image](https://github.com/microsoft/terminal/assets/11061796/677953e7-fd56-4a72-9c3e-0b67631d5cdd) ### Actual Behavior Window is reisized but internal structure get corrupt. Notice the cursor moved outside it normal position. I think this is a result of adapation maked by WindowsTerminal itself. ![image](https://github.com/microsoft/terminal/assets/11061796/b97905f8-136e-460b-b1cd-9f87ae4f0beb) But most unix terminal programs can handle terminal resize notification. It will be very nice to have it for seamless integration.
claunia added the Needs-TriageIssue-BugNeeds-Attention labels 2026-01-31 07:56:16 +00:00
Author
Owner

@DHowett commented on GitHub (Jun 7, 2024):

Thanks for filing! Are you running QEMU-for-Windows or QEMU inside WSL? There is a standard resize message that the Windows console subsystem generates, and I would guess that qemu-for-win is not handling it.

For what it's worth, running something inside qemu's serial console is much more specific than just "unix/linux programs" 🙂

@DHowett commented on GitHub (Jun 7, 2024): Thanks for filing! Are you running QEMU-for-Windows or QEMU inside WSL? There is a standard resize message that the Windows console subsystem generates, and I would guess that qemu-for-win is not handling it. For what it's worth, running something _inside qemu's serial console_ is much more specific than just "unix/linux programs" 🙂
Author
Owner

@ant5 commented on GitHub (Jun 11, 2024):

Hello!
I'm using QEMU-for-Windows.
As I understand QEMU just put data from emulated-for-guest COM-port to the stdout and let stdin go to the COM-port.

I think the first question is: Does the terminal resize generate special escape sequence that goes to stdin of a process attached to the terminal?

@ant5 commented on GitHub (Jun 11, 2024): Hello! I'm using QEMU-for-Windows. As I understand QEMU just put data from emulated-for-guest COM-port to the stdout and let stdin go to the COM-port. I think the first question is: Does the terminal resize generate special escape sequence that goes to stdin of a process attached to the terminal?
Author
Owner

@DHowett commented on GitHub (Jun 11, 2024):

I think the first question is: Does the terminal resize generate special escape sequence that goes to stdin of a process attached to the terminal?

It does not. This is true of all terminal emulators on all platforms.

On Linux and POSIX-compatible equivalents, the TTY or PTY driver sends SIGWINCH (the window change signal.) It does not generate VT.

On Windows, the console subsystem inserts a WINDOW_BUFFER_SIZE_EVENT into the input stream, which WSL and most POSIX translation layers translate into SIGWINCH.

I do not believe there is a standard in-band signal for window size changes. QEMU-for-Windows should be listening for WINDOW_BUFFER_SIZE_EVENT... however: serial ports typically do not resize. There may not be an in-band signal that its serial port emulation can use to cause the guest OS to generate a SIGWINCH.

I cannot find any window handling in QEMU's code that would give support for window resizing to the ISA or PCI serial devices. 🙂

@DHowett commented on GitHub (Jun 11, 2024): > I think the first question is: Does the terminal resize generate special escape sequence that goes to stdin of a process attached to the terminal? It does not. This is true of all terminal emulators on all platforms. On Linux and POSIX-compatible equivalents, the TTY or PTY driver sends `SIGWINCH` (the window change signal.) It does not generate VT. On Windows, the console subsystem inserts a `WINDOW_BUFFER_SIZE_EVENT` into the input stream, which WSL and most POSIX translation layers translate into `SIGWINCH`. I do not believe there is a standard in-band signal for window size changes. QEMU-for-Windows should be listening for `WINDOW_BUFFER_SIZE_EVENT`... however: serial ports typically do not resize. There may not be an in-band signal that its serial port emulation can use to _cause_ the guest OS to generate a `SIGWINCH`. I cannot find any window handling in QEMU's code that would give support for window resizing to the ISA or PCI serial devices. 🙂
Author
Owner

@DHowett commented on GitHub (Jun 11, 2024):

PuTTY doesn't even do anything when the window size changes for a serial connection!

Image

@DHowett commented on GitHub (Jun 11, 2024): PuTTY [doesn't even do anything](https://github.com/github/putty/blob/7003b43963aef6cdf2841c2a882a684025f1d806/unix/uxser.c#L484) when the window size changes for a serial connection! ![Image](https://github.com/microsoft/terminal/assets/189190/14bf30f6-ee7d-4cb2-82f7-205d614f8f7c)
Author
Owner

@ant5 commented on GitHub (Jun 12, 2024):

Hmm...

Really there is a separate technique of resize notification:

https://github.com/contour-terminal/contour/discussions/1236#discussioncomment-7222641

But things work over ssh so I'm wondering does an ssh/telnet protocol cover this case.

Also I'm wandering was there a hardware terminal that can switch screen size and how do they do it over serial line. May be I'll ask somebodies in invisible island about this if they are reachable...

@ant5 commented on GitHub (Jun 12, 2024): Hmm... Really there is a separate technique of resize notification: https://github.com/contour-terminal/contour/discussions/1236#discussioncomment-7222641 But things work over ssh so I'm wondering does an ssh/telnet protocol cover this case. Also I'm wandering was there a hardware terminal that can switch screen size and how do they do it over serial line. May be I'll ask somebodies in invisible island about this if they are reachable...
Author
Owner

@DHowett commented on GitHub (Jun 12, 2024):

Really there is a separate technique of resize notification:

contour-terminal/contour#1236 (reply in thread)

The comment you linked to says this:

Size change -> TE resizes PTY with syscall -> application receives SIGWINCH -> TUI queries size from TE or with a SYSCALL -> response

Which is exactly what I described above. There doesn't seem to be another way 🙂

If you find another way to handle this, please feel free to comment here and I will reopen the issue! Thanks so much!

@DHowett commented on GitHub (Jun 12, 2024): > Really there is a separate technique of resize notification: > > [contour-terminal/contour#1236 (reply in thread)](https://github.com/contour-terminal/contour/discussions/1236#discussioncomment-7222641) The comment you linked to says this: > Size change -> TE resizes PTY with syscall -> application receives SIGWINCH -> TUI queries size from TE or with a SYSCALL -> response Which is exactly what I described above. There doesn't seem to be another way 🙂 If you find another way to handle this, please feel free to comment here and I will reopen the issue! Thanks so much!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#21842