question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pipe waits for the first command to be finished

See original GitHub issue

Since there are 281 open issues, I’m not sure if this is reported before or not

Try a command that takes too long (possibly forever) and produces lots of output, and we want to give the output to another command using pipe, for example:

find / -iname '*.exe' | less

PowerShell waits for the first command to be finished, and then runs the second command and give it the whole output. That is not what Unix pipes have been about for decades! We expect the second command to be executed right after we press enter (try sleep 10 | echo test in Bash), and send any output from first command immediately to the second command.

Tested with PowerShell 6.0.0 on Debian GNU/Linux

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:5
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
RamblingCookieMonstercommented, Aug 19, 2016

Hi!

@kilasuit, I could be off base, but IIRC commands with a proper process block implementation will stream their output, allowing something akin to @ilius’ example.

I’m guessing there might be some odd behavior if you mix and match output from *nix tools and PowerShell tools, and this would be expected in cases where you have a blocking command (e.g. you need all items to sort them).

Cheers!

2reactions
iliuscommented, Aug 20, 2016

I can’t see how this breaks compatibility If a command (like ``Sort-ObjectorSelect-Object`) needs the whole input to process, it can wait for the whole input itself, that’s up to the second command (receiver), that does not prevent the first command (sender) or the Shell to send it’s output.

https://en.wikipedia.org/wiki/Pipeline_(Unix)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why doesn't the 2nd command wait for the output of the 1st ...
In a pipeline producer | consumer , the two sides run concurrently¹. The consumer does not wait for the producer to finish. It...
Read more >
How to pipe without waiting for first command to finish?
In Windows PowerShell, when piping to an external program, the input command's output is unexpectedly: collected in full in memory first.
Read more >
Bash wait Command with Examples
Introduction. The bash wait command is a Shell command that waits for background running processes to complete and returns the exit status.
Read more >
Do pipes know when they have to "wait" for all the data?
Hi, I was wondering if pipes ("|"), or rather the command that follow them, know when they're supposed to wait for all the...
Read more >
Bash wait Command with Examples
The wait command is a built-in Bash shell command that waits for termination of a background process. This means that Bash shell will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found