From 2102a833329658499d4c1490f3ccb14b52fdcb36 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 23 Jun 2023 23:27:06 -0400 Subject: [PATCH] Guard against PInvoke exceptions calling sd_notify --- src/Tgstation.Server.Host/System/SystemDManager.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Tgstation.Server.Host/System/SystemDManager.cs b/src/Tgstation.Server.Host/System/SystemDManager.cs index dd77727e21..99f4ade686 100644 --- a/src/Tgstation.Server.Host/System/SystemDManager.cs +++ b/src/Tgstation.Server.Host/System/SystemDManager.cs @@ -222,7 +222,17 @@ namespace Tgstation.Server.Host.System bool SendSDNotify(string command) { logger.LogTrace("Sending sd_notify {message}...", command); - var result = NativeMethods.sd_notify(0, command); + int result; + try + { + result = NativeMethods.sd_notify(0, command); + } + catch (Exception ex) + { + logger.LogInformation(ex, "Exception attempting to invoke sd_notify!"); + return false; + } + if (result > 0) return true;