From fbd82bbce8802b0b5a10f836410aeaa7de0c0ef1 Mon Sep 17 00:00:00 2001 From: Luke Date: Tue, 22 Nov 2022 16:40:39 +1000 Subject: [PATCH] Prevent installer from closing via ctrl+c while server remains open This allows tshock to handle CancelKeyPress as per normal, instead of closing the parent process, leaving the second trigger to never be reached. see https://github.com/Pryaxis/TShock/blob/general-devel/TShockAPI/TShock.cs#L710 --- TShockInstaller/Program.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/TShockInstaller/Program.cs b/TShockInstaller/Program.cs index 700aadd1..50b9a541 100644 --- a/TShockInstaller/Program.cs +++ b/TShockInstaller/Program.cs @@ -95,7 +95,14 @@ Console.WriteLine($"To be able to run {tshock_path} yourself set the environment Environment.SetEnvironmentVariable("DOTNET_ROOT", dotnet_root); Console.WriteLine($"Extracted, launching: {tshock_path}"); + var proc = new Process(); + +Console.CancelKeyPress += (sender, e) => +{ + e.Cancel = !proc.HasExited; +}; + proc.StartInfo = new() { FileName = tshock_path,