PowerShell cannot have a pipeline with more then 2 native processes with redirected stdin

Created on 13 Mar 2017  路  12Comments  路  Source: PowerShell/PowerShell

Steps to reproduce

ps aux | grep powershell | grep -v grep

Expected behavior

Return filtered results. I.e. same as

PS > $a = ps aux | grep powershell; $a | grep -v grep
vors          2995   7.4  0.3  4813880  44460 s000  S+   11:07AM   0:10.07 -powershell
vors          6628   0.0  0.1  4810520  19192 s001  S+   11:35AM   0:02.51 -powershell

Actual behavior

Pipeline hanging (first grep never receives "output closed" event, besides the fact that corresponding stream is disposed)

Environment data

> $PSVersionTable
Name                           Value                                                                                                                                                       
----                           -----                                                                                                                                                       
PSVersion                      6.0.0-alpha                                                                                                                                                 
PSEdition                      Core                                                                                                                                                        
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                     
BuildVersion                   3.0.0.0                                                                                                                                                     
GitCommitId                    v6.0.0-alpha.17                                                                                                                                             
CLRVersion                                                                                                                                                                                 
WSManStackVersion              3.0                                                                                                                                                         
PSRemotingProtocolVersion      2.3                                                                                                                                                         
SerializationVersion           1.1.0.1    
Issue-Bug OS-Linux OS-macOS Resolution-External Resolution-Fixed WG-Engine

Most helpful comment

The PR has been merged to dotnet/master and ported to release/2.0 branch.: https://github.com/dotnet/corefx/pull/20001

I also verified that this issue doesn't repro with the fix in .NET Core 2.0:

PS /home> ps aux | grep powershell | grep -v grep                                            
dongbo   22410  4.0  0.8 3697196 104800 pts/2  SLl+ 17:02   0:04 powershell
PS /home>

Hence, I'm closing this issue.

All 12 comments

It's blocked on https://github.com/dotnet/corefx/issues/13447

I'd treat it is a high priority, because it makes impossible to have any pipeline with 2 or more native commands (when both have stdin redirected).

The simpler repro is 1 | grep 1 | grep 1

CC @joeyaiello

I submitted a PR to fix dotnet/corefx#13447. The PR is at https://github.com/dotnet/corefx/pull/19988

The PR has been merged to dotnet/master and ported to release/2.0 branch.: https://github.com/dotnet/corefx/pull/20001

I also verified that this issue doesn't repro with the fix in .NET Core 2.0:

PS /home> ps aux | grep powershell | grep -v grep                                            
dongbo   22410  4.0  0.8 3697196 104800 pts/2  SLl+ 17:02   0:04 powershell
PS /home>

Hence, I'm closing this issue.

@daxian-dbw that's awesome, thank you so much!!

I get the old behavior on beta-2

image

Did we not have a test for this?

@daxian-dbw is it just not yet included in the dotnet packages we consume?

We haven't moved to the lastest dotnet preview2 packages yet because preview2 packages will break VSCode. preview2 packages are not supported by VSCode C# extension at this moment, see https://github.com/OmniSharp/omnisharp-vscode/issues/1495

PowerShell has moved to the latest 2.0.0-preview2 packages via #3887.
A test is also added with #4012 to cover this scenario.

We are moving back to .NET Core 2.0.0-preview1 via PR #4026 due to regressions in the latest .NET Core 2.0.0-preview2 (https://github.com/dotnet/corefx/issues/21095). So re-open this bug.

We finally moved to .NET Core 2.0.0-preview3 via PR #4144.
I have verified this issue has been fixed.

Was this page helpful?
0 / 5 - 0 ratings