Fix deadlock when piping to shell associated file extension (#19940)

This commit is contained in:
Patrick Meinecke
2023-07-17 11:10:35 -07:00
committed by GitHub
parent d372832325
commit 153feb2e60
@@ -604,19 +604,6 @@ namespace System.Management.Automation
{
_nativeProcess = new Process() { StartInfo = startInfo };
_nativeProcess.Start();
if (UpstreamIsNativeCommand)
{
SemaphoreSlim processInitialized = _processInitialized;
if (processInitialized is null)
{
lock (_sync)
{
processInitialized = _processInitialized ??= new SemaphoreSlim(0, 1);
}
}
processInitialized?.Release();
}
}
catch (Win32Exception)
{
@@ -695,6 +682,12 @@ namespace System.Management.Automation
}
#endif
}
if (UpstreamIsNativeCommand)
{
_processInitialized ??= new SemaphoreSlim(0, 1);
_processInitialized.Release();
}
}
if (this.Command.MyInvocation.PipelinePosition < this.Command.MyInvocation.PipelineLength)