Skip to content

Comments

fix(windows): exit process on WM_ENDSESSION#1157

Open
Legend-Master wants to merge 2 commits intotauri-apps:devfrom
Legend-Master:wm-endsession-exit
Open

fix(windows): exit process on WM_ENDSESSION#1157
Legend-Master wants to merge 2 commits intotauri-apps:devfrom
Legend-Master:wm-endsession-exit

Conversation

@Legend-Master
Copy link
Contributor

Reference: tauri-apps/tauri#14479 (comment)

Open to suggestion on this one, we can detect lParam here to do special handling to Restart Manager but I honestly feel like the Windows shutdown behavior itself is a bit of a myth so might just to the exit ourselves regardlesss

@Legend-Master Legend-Master requested a review from a team as a code owner November 21, 2025 13:09
@github-actions
Copy link
Contributor

github-actions bot commented Nov 21, 2025

Package Changes Through 3363fcc

There are 1 changes which include tao with patch

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
tao 0.34.5 0.34.6

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

@Legend-Master
Copy link
Contributor Author

After the testing in rust-windowing/winit#4425 (comment), I think it should be possible to exit normally without the std::process:exit here, but that requires us to adopt rust-windowing/winit#2767 or our current way of pulling the message through GetMessageW (GetMessageW dispatches none queued messages by itself and only returns on queued messages) will not return to us (or maybe we can post a message to the message queue?)

// - From Restart Manager: Restart Manager only sends the message but will wait for us to shutdown ourselves
//
// So, we call `exit` here directly to align this behavior
std::process::exit(0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does also happen in the run_return case? I would really like to not have this then as we want to do some graceful cleanup before exiting.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does also happen in the run_return case?

This happens in all cases when you spin the event loop, and yes, including run_return. One thing to note here is no matter what we do here, during shutdown, Windows will terminate us anyways

This does trigger Exit event for you to do some clean ups though

Copy link
Contributor

@thomaseizinger thomaseizinger Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does trigger Exit event for you to do some clean ups though

I don't quite understand that. If you call process exit here, no more code can execute after this, right?

I don't know the details of WM_ENDSESSION but why can't we just gracefully exit the event-loop here? What would be the point of a signal from Windows if we can't run a few more instructions to shut down?

Exiting the process should IMO be reserved for the binary that embeds Tauri and not happen in Tauri itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite understand that. If you call process exit here, no more code can execute after this, right?

Yes, the event handler is called in the line above

subclass_input.event_loop_runner.loop_destroyed();


I don't know the details of WM_ENDSESSION but why can't we just gracefully exit the event-loop here? What would be the point of a signal from Windows if we can't run a few more instructions to shut down?

Exiting the process should IMO be reserved for the binary that embeds Tauri and not happen in Tauri itself.

In the Windows shutdown case, you're supposed to block the event loop (not returning from the window procedure) to do the clean up, and once you return, Windows terminates the app if you don't do it yourselves

For the restart manager case, see my comment above #1157 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants