Skip to content

Commit 4598ad0

Browse files
committed
DnsServerApp: updated code to keep posix signal registration handle to prevent it from getting unregistered due to garbage collector.
1 parent 89e51cb commit 4598ad0

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

DnsServerApp/Program.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ static async Task Main(string[] args)
5353
ManualResetEvent waitHandle = new ManualResetEvent(false);
5454
ManualResetEvent exitHandle = new ManualResetEvent(false);
5555
DnsWebService? service = null;
56+
PosixSignalRegistration? psr = null;
5657

5758
try
5859
{
@@ -86,9 +87,8 @@ static async Task Main(string[] args)
8687

8788
if (Environment.OSVersion.Platform == PlatformID.Unix)
8889
{
89-
PosixSignalRegistration.Create(PosixSignal.SIGTERM, delegate (PosixSignalContext context)
90+
psr = PosixSignalRegistration.Create(PosixSignal.SIGTERM, delegate (PosixSignalContext context)
9091
{
91-
context.Cancel = true;
9292
waitHandle.Set();
9393
exitHandle.WaitOne();
9494
});
@@ -107,6 +107,7 @@ static async Task Main(string[] args)
107107
Console.WriteLine("\r\nTechnitium DNS Server is stopping...");
108108

109109
service?.Dispose();
110+
psr?.Dispose();
110111

111112
Console.WriteLine("Technitium DNS Server was stopped successfully.");
112113
exitHandle.Set();

0 commit comments

Comments
 (0)