-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Process.WaitForExit(Int32) sometimes throws AggregateException on macOS #85717
Comments
Tagging subscribers to this area: @dotnet/area-system-diagnostics-process Issue DetailsDescription
Reproduction StepsThe following code snippet will trigger the issue on macOS (usually after several seconds, but sometimes it will take 1-2 minutes): for (int i = 0; ; ++i)
{
try
{
var process = Process.GetCurrentProcess();
process.WaitForExit(10);
}
catch
{
Console.WriteLine($"{nameof(Process.WaitForExit)} failed in iteration {i}");
throw;
}
} It doesn't matter which process instance was used (that is, you can use any active process and call Expected behavior
Actual behavior
Regression?The issue is present at least in .NET 6.0, 7.0, and 8.0. Known WorkaroundsNo response Configuration
Other informationNo response
|
runtime/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessWaitState.Unix.cs Line 551 in e61e022
It seems that Task.Run could be unexpectedly cancelled by this token. In such a situation the delegate doesn't run and let the |
Either of you interested in offering a PR? |
@danmoseley I'd like to have a try. Could you please assign it to me? |
Done! |
Description
Process.WaitForExit(Int32)
overload sometimes unexpectedly throwsAggregateException
(withTaskCanceledException
inside). The issue can be reliably reproduced on macOS, but it doesn't seem to be happening on Windows.Reproduction Steps
The following code snippet will trigger the issue on macOS (usually after several seconds, but sometimes it will take 1-2 minutes):
It doesn't matter which process instance was used (that is, you can use any active process and call
Process.GetProcessById
).Expected behavior
Process.WaitForExit(Int32)
shouldn't throwAggregateException
.Actual behavior
Process.WaitForExit(Int32)
throwsAggregateException
on macOS (but not on Windows):Regression?
The issue is present at least in .NET 6.0, 7.0, and 8.0.
Known Workarounds
No response
Configuration
Other information
No response
The text was updated successfully, but these errors were encountered: