Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion test/IntegrationTests/WcfTestsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

using System.Net.Sockets;
using System.Runtime.InteropServices;
using IntegrationTests.Helpers;
using Xunit.Abstractions;
using static OpenTelemetry.Proto.Trace.V1.Span.Types;
Expand Down Expand Up @@ -45,7 +46,11 @@ protected virtual void Dispose(bool disposing)
}
else
{
_serverProcess.Process.Kill();
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) || !SendSigTerm(_serverProcess.Process.Id))
{
_serverProcess.Process.Kill();
}

_serverProcess.Process.WaitForExit();
}

Expand Down Expand Up @@ -122,4 +127,26 @@ private async Task WaitForServer()

Assert.Fail("WCF Server did not open the port.");
}

[DllImport("libc", SetLastError = true)]
#pragma warning disable CA5392 // Use DefaultDllImportSearchPaths attribute for P/Invokes
#pragma warning disable SA1204 // Static elements should appear before instance elements
#pragma warning disable SA1300 // Element should begin with upper-case letter
private static extern int kill(int pid, int sig);
#pragma warning restore SA1300 // Element should begin with upper-case letter
#pragma warning restore SA1204 // Static elements should appear before instance elements
#pragma warning restore CA5392 // Use DefaultDllImportSearchPaths attribute for P/Invokes

private static bool SendSigTerm(int processId)
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
const int sigTerm = 15;
var result = kill(processId, sigTerm);

return result == 0;
}

return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
// Configure NetTcp transport
builder.WebHost.UseNetTcp(9090);

var app = builder.Build();
using var app = builder.Build();

// Configure CoreWCF
app.UseServiceModel(serviceBuilder =>
Expand Down
Loading