Fix service crashes (#680)

This commit is contained in:
Next Turn
2020-09-03 21:44:20 +08:00
committed by GitHub
parent bff88217d3
commit 7c61b9c43c
3 changed files with 20 additions and 3 deletions

View File

@@ -4,6 +4,7 @@ using System.Diagnostics;
using System.Management;
using System.Threading;
using log4net;
using WinSW.Native;
namespace WinSW.Util
{
@@ -168,7 +169,19 @@ namespace WinSW.Util
}
}
processToStart.Start();
bool succeeded = ConsoleApis.SetConsoleCtrlHandler(null, false); // inherited
Debug.Assert(succeeded);
try
{
processToStart.Start();
}
finally
{
succeeded = ConsoleApis.SetConsoleCtrlHandler(null, true);
Debug.Assert(succeeded);
}
Logger.Info("Started process " + processToStart.Id);
if (priority != null)