Make Process.WaitForExitAsync wait for redirected output reads (#42585)
authorEirik Tsarpalis <eirik.tsarpalis@gmail.com>
Mon, 28 Sep 2020 16:22:44 +0000 (17:22 +0100)
committerGitHub <noreply@github.com>
Mon, 28 Sep 2020 16:22:44 +0000 (17:22 +0100)
commit1ea8eb16c7f5d90160e6f58a1bf8230dee73ea55
tree2089256c0b9ce950c502e821114e79dea7dce00b
parent84fae52d6511aa76be9debbe997fb1ac10d73570
Make Process.WaitForExitAsync wait for redirected output reads (#42585)

* Make Process.WaitForExitAsync wait for output reads

Addresses an issue where Process.WaitForExitAsync
doesn't wait for background redirected output reads,
a behaviour which diverges from the sync method
equivalent. Fixes #42556.

* address feedback

* pass cancellation token to AsyncStreamReader waiter

* address feedback

* use tcs.TrySetResult

* Update src/libraries/Common/src/System/Threading/Tasks/TaskTimeoutExtensions.cs

Co-authored-by: Stephen Toub <stoub@microsoft.com>
Co-authored-by: Stephen Toub <stoub@microsoft.com>
src/libraries/Common/src/System/Threading/Tasks/TaskTimeoutExtensions.cs [new file with mode: 0644]
src/libraries/System.Diagnostics.Process/src/System.Diagnostics.Process.csproj
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/AsyncStreamReader.cs
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Windows.cs
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.cs
src/libraries/System.Diagnostics.Process/tests/ProcessWaitingTests.cs
src/libraries/System.Diagnostics.Process/tests/RemotelyInvokable.cs