Skip to content

Commit

Permalink
[dotnet] Kill entire process tree when stopping test web server
Browse files Browse the repository at this point in the history
  • Loading branch information
nvborisenko committed Dec 1, 2023
1 parent 94b566d commit 3384df3
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions dotnet/test/common/Environment/TestWebServer.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using Bazel;
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Diagnostics;
using System.Text;
using OpenQA.Selenium.Internal;
using NUnit.Framework;
using System.Net.Http;

namespace OpenQA.Selenium.Environment
{
Expand Down Expand Up @@ -150,14 +148,8 @@ public void Start()

public void Stop()
{
HttpWebRequest request = WebRequest.Create(EnvironmentManager.Instance.UrlBuilder.LocalWhereIs("quitquitquit")) as HttpWebRequest;
try
{
request.GetResponse();
}
catch (WebException)
{
}
using var httpClient = new HttpClient();
using var quitResponse = httpClient.GetAsync(EnvironmentManager.Instance.UrlBuilder.LocalWhereIs("quitquitquit")).GetAwaiter().GetResult();

if (webserverProcess != null)
{
Expand All @@ -166,12 +158,9 @@ public void Stop()
webserverProcess.WaitForExit(10000);
if (!webserverProcess.HasExited)
{
webserverProcess.Kill();
webserverProcess.Kill(entireProcessTree: true);
}
}
catch (Exception)
{
}
finally
{
webserverProcess.Dispose();
Expand Down

0 comments on commit 3384df3

Please sign in to comment.