From 28cd70124256f5d3b641a2b904a617fa7b9098e5 Mon Sep 17 00:00:00 2001 From: kuba Date: Mon, 28 Sep 2026 17:43:37 +0200 Subject: [PATCH] [CLI] Shut down cooperatively on SIGTERM SIGTERM (launchd, process managers, kill) used the runtime default and exited with GPU work in flight. It now takes the same host-interrupt path as Ctrl+C: the presenter closes and tears Vulkan down before exit. --- src/SharpEmu.CLI/Program.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/SharpEmu.CLI/Program.cs b/src/SharpEmu.CLI/Program.cs index 0707bb3..197e9f3 100644 --- a/src/SharpEmu.CLI/Program.cs +++ b/src/SharpEmu.CLI/Program.cs @@ -323,6 +323,16 @@ internal static partial class Program VideoOutExports.NotifyHostInterrupt(); }; Console.CancelKeyPress += cancelHandler; + // SIGTERM (launchd, process managers, `kill`) takes the same cooperative shutdown: the + // runtime's default exits with GPU work in flight, which leaves the host driver to reclaim + // resources the device still owns. + using var terminateRegistration = OperatingSystem.IsWindows() + ? null + : PosixSignalRegistration.Create(PosixSignal.SIGTERM, context => + { + context.Cancel = true; + VideoOutExports.NotifyHostInterrupt(); + }); Console.Error.WriteLine($"[DEBUG] Running: {ebootPath}"); result = runtime.Run(ebootPath);