[PR #17714] Fix session persistence when the session ends #31336

Open
opened 2026-01-31 09:46:38 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/17714

State: closed
Merged: Yes


Once all applications that have received a WM_ENDSESSION message
have returned from processing said message, windows will terminate
all processes. This forces us to process the message synchronously.
This meant that this issue was timing dependent. If Windows Terminal
was quick at persisting buffers and you had some other application that
was slow to shut down (e.g. Steam), you would never see this issue.

Closes #17179
Closes #17250

Validation Steps Performed

  • Set up a lean Hyper-V VM for fast reboots
  • Set-VMComPort <vm> 1 \\.pipe\\<pipe>
  • Hook up WIL to write to COM1
  • Add a ton of debug prints all over the place
  • Read COM output with Putty for hours
  • RTFM, and notice that the WM_ENDSESSION documentation states
    "the session can end any time after all applications
    have returned from processing this message"
  • Be very very sad
  • Fix it
  • Rebooting now shows on COM1 that persistence runs
  • Windows get restored after reboot
**Original Pull Request:** https://github.com/microsoft/terminal/pull/17714 **State:** closed **Merged:** Yes --- Once all applications that have received a `WM_ENDSESSION` message have returned from processing said message, windows will terminate all processes. This forces us to process the message synchronously. This meant that this issue was timing dependent. If Windows Terminal was quick at persisting buffers and you had some other application that was slow to shut down (e.g. Steam), you would never see this issue. Closes #17179 Closes #17250 ## Validation Steps Performed * Set up a lean Hyper-V VM for fast reboots * `Set-VMComPort <vm> 1 \\.pipe\\<pipe>` * Hook up WIL to write to COM1 * Add a ton of debug prints all over the place * Read COM output with Putty for hours * RTFM, and notice that the `WM_ENDSESSION` documentation states "the session can end any time after all applications have returned from processing this message" * Be very very sad ✅ * Fix it * Rebooting now shows on COM1 that persistence runs ✅ * Windows get restored after reboot ✅
claunia added the pull-request label 2026-01-31 09:46:38 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#31336