Skip to content

Commit 642bcb8

Browse files
SimonCroppCopilot
andauthored
Use WaitForExitAsync from polyfill (#7460)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent e8ef59e commit 642bcb8

1 file changed

Lines changed: 2 additions & 10 deletions

File tree

src/Platform/Microsoft.Testing.Extensions.HangDump/Helpers/IProcessExtensions.cs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,9 @@ internal static async Task<int> GetParentPidMacOsAsync(Process process, ILogger
118118
ps.BeginErrorReadLine();
119119

120120
int timeout = 5_000;
121-
#if !NETSTANDARD2_0
122121
// This will read the output streams till the end.
123-
await ps.WaitForExitAsync(new CancellationTokenSource(timeout).Token).ConfigureAwait(false);
124-
#else
125-
// This won't read the streams till the end. If we timeout, we need to use the
126-
// wait without timeout, but that can hang, so we offload that into a task so we can abandon it and continue.
127-
if (!ps.WaitForExit(timeout))
128-
{
129-
await Task.Run(ps.WaitForExit, new CancellationTokenSource(timeout).Token).ConfigureAwait(false);
130-
}
131-
#endif
122+
using var cts = new CancellationTokenSource(timeout);
123+
await ps.WaitForExitAsync(cts.Token).ConfigureAwait(false);
132124

133125
string o = output.ToString();
134126
string e = err.ToString();

0 commit comments

Comments
 (0)