Skip to content

Commit 36a75f3

Browse files
committed
Kill only if not exited yet
1 parent 9c57c68 commit 36a75f3

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

test/Utilities/Microsoft.Testing.TestInfrastructure/CommandLine.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,11 @@ private static string ClearBOM(string outputLine)
8686
return firstChar == byteOrderMark ? outputLine[1..] : outputLine;
8787
}
8888

89-
public void Dispose() => _process?.Kill();
89+
public void Dispose()
90+
{
91+
if (_process?.HasExited == false)
92+
{
93+
_process.Kill();
94+
}
95+
}
9096
}

test/Utilities/Microsoft.Testing.TestInfrastructure/IProcessHandle.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public interface IProcessHandle
1515

1616
TextReader StandardOutput { get; }
1717

18+
bool HasExited { get; }
19+
1820
void Dispose();
1921

2022
void Kill();

test/Utilities/Microsoft.Testing.TestInfrastructure/ProcessHandle.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ internal ProcessHandle(Process process, ProcessHandleInfo processHandleInfo)
2424

2525
public TextReader StandardOutput => _process.StandardOutput;
2626

27+
public bool HasExited => _process.HasExited;
28+
2729
public int ExitCode => _process.ExitCode;
2830

2931
public async Task<int> WaitForExitAsync(CancellationToken cancellationToken = default)

0 commit comments

Comments
 (0)