fix processex.cs possible problems (#22347)
- `_output ` May be executed in synchronous and asynchronous situations - Process Is a nullable
This commit is contained in:
parent
78d6ce201f
commit
22c36ad0f0
|
|
@ -196,8 +196,12 @@ namespace Microsoft.AspNetCore.Internal
|
|||
|
||||
var exited = Exited.Wait(timeSpan.Value);
|
||||
if (!exited)
|
||||
{
|
||||
lock (_testOutputLock)
|
||||
{
|
||||
_output.WriteLine($"The process didn't exit within the allotted time ({timeSpan.Value.TotalSeconds} seconds).");
|
||||
}
|
||||
|
||||
_process.Dispose();
|
||||
}
|
||||
else if (assertSuccess && _process.ExitCode != 0)
|
||||
|
|
@ -227,6 +231,8 @@ namespace Microsoft.AspNetCore.Internal
|
|||
_process.KillTree();
|
||||
}
|
||||
|
||||
if (_process != null)
|
||||
{
|
||||
_process.CancelOutputRead();
|
||||
_process.CancelErrorRead();
|
||||
|
||||
|
|
@ -236,4 +242,5 @@ namespace Microsoft.AspNetCore.Internal
|
|||
_process.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue