Browse Source

process needs to be disposed of (#252)

davidfowl/build-earlier
Simon Cropp 7 years ago
committed by GitHub
parent
commit
eface3f3b3
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      src/Microsoft.Tye.Core/ProcessUtil.cs
  2. 10
      src/Microsoft.Tye.Hosting/ProcessRunner.cs

3
src/Microsoft.Tye.Core/ProcessUtil.cs

@ -144,7 +144,8 @@ namespace Microsoft.Tye
{
try
{
Process.GetProcessById(pid)?.Kill();
using var process = Process.GetProcessById(pid);
process?.Kill();
}
catch (ArgumentException) { }
catch (InvalidOperationException) { }

10
src/Microsoft.Tye.Hosting/ProcessRunner.cs

@ -332,8 +332,8 @@ namespace Microsoft.Tye.Hosting
private static string? GetDotnetRoot()
{
var process = Process.GetCurrentProcess();
var entryPointFilePath = process.MainModule.FileName;
var entryPointFilePath = GetEntryPointFilePath();
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) &&
Path.GetFileNameWithoutExtension(entryPointFilePath) == "dotnet")
{
@ -347,6 +347,12 @@ namespace Microsoft.Tye.Hosting
return null;
}
private static string GetEntryPointFilePath()
{
using var process = Process.GetCurrentProcess();
return process.MainModule.FileName;
}
private class ProcessInfo
{

Loading…
Cancel
Save