Guard against PInvoke exceptions calling sd_notify

This commit is contained in:
Jordan Dominion
2023-06-23 23:27:06 -04:00
parent 259eb8b2b3
commit 2102a83332
@@ -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;