Windows 0.3.7 updater exit and Windows session cleanup reliability; no private history or other platform changes

This commit is contained in:
2026-11-07 04:05:04 +00:00
parent ac40dd3a6c
commit 1590443809
15 changed files with 608 additions and 80 deletions
+20 -15
View File
@@ -11,6 +11,19 @@ internal static class Program
[STAThread]
private static int Main(string[] args)
{
if (args.Length == 1 && args[0] == "--client-shutdown-self-test")
{
ApplicationConfiguration.Initialize();
return ClientShutdownSelfTest.Run();
}
if (args.Length == 3 && args[0] == "--client-shutdown-test-child"
&& int.TryParse(args[1], out var childDelay) && childDelay is >= 10 and <= 2000
&& int.TryParse(args[2], out var childExit) && childExit is 0 or 7)
{
Thread.Sleep(childDelay);
return childExit;
}
if (args.Any(a => a.StartsWith("--client-shutdown-test-child", StringComparison.OrdinalIgnoreCase))) return 87;
if (args.Length == 5 && args[0] is "--installer-guardian-gate" or "--installer-guardian-apply")
return InstallerGuardianGate.Run(args[1], args[2], args[3], args[4], apply: args[0] == "--installer-guardian-apply");
// Malformed maintenance arguments must never fall through to the GUI.
@@ -195,9 +208,12 @@ internal static class Program
shutdownEvent,
(_, _) =>
{
var form = Application.OpenForms.OfType<MainForm>().FirstOrDefault();
if (form is null || form.IsDisposed || !form.IsHandleCreated) return;
form.BeginInvoke(form.RequestExit);
try
{
if (!mainForm.IsDisposed && mainForm.IsHandleCreated)
mainForm.BeginInvoke(mainForm.RequestExitForUpdate);
}
catch (InvalidOperationException) { /* A concurrent close destroyed the HWND. */ }
},
null,
Timeout.Infinite,
@@ -335,18 +351,7 @@ internal static class Program
foreach (var process in processes) process.CloseMainWindow();
}
foreach (var process in processes)
{
using (process)
{
if (!process.WaitForExit(15_000))
{
return 2;
}
if (process.ExitCode != 0) return 2;
}
}
return 0;
return ClientShutdownScope.WaitForExit(processes) ? 0 : 2;
}
catch
{