Earlier quoted context omitted.
Well, in any case, the problem can be resolved by adding a kernel-level api function that allows one to wait (block) until results are requested from the other end of the pipe.
Why? The opposite is already true and has the same effect. Each stage of the pipeline is executed when it has data to execute. So ultimately the main blocking event is IO (normally the first stage in a pipeline). Every other process is automatically marked as blocked, until its stdin is populated by the output of the former. Once its task is complete it re-checks stdin, and if nothing is present blocks itself. So the…
The Mighty Named Pipe
91–99 of 99 posts
Re: The Mighty Named Pipe
#92Nice article. Really easy to follow introduction. I only discovered process substitution a few months ago but it's already become a frequently used tool in my kit. One thing that I find a little annoying about unix commands sometimes is how hard it can be to google for them. ' Unless you know to look for "Process Substitution" it can be hard to find information on these things. And that's once you even know these thi…
For this in particular, try the Advanced Bash Scripting doc, http://www.tldp.org/LDP/abs/html/ There's a bunch of interesting constructs there. Most of them also apply to improved shells such as zsh, though some are just pointless there.
Which itself recommends as best (current) alternative: Greg's Bash Guide: http://mywiki.wooledge.org/BashGuide
Re: The Mighty Named Pipe
#93Nice article. Really easy to follow introduction. I only discovered process substitution a few months ago but it's already become a frequently used tool in my kit. One thing that I find a little annoying about unix commands sometimes is how hard it can be to google for them. ' Unless you know to look for "Process Substitution" it can be hard to find information on these things. And that's once you even know these thi…
Be aware that process substitution (and named pipes) can bite you in the arse in some situations --- for example, if the program expects to be able to seek in the file. Pipes don't support this and the program will see it as an I/O error. This'd be fine if programs just errored out cleanly but they frequently don't check that seeking succeeds. unzip treats a named pipe as a corrupt zipfile, for example: $ unzip
cat z | unzip # I know, uuoc, demo only
It's just with the process substitution you have more flexibility to shoot yourself in the foot?Re: The Mighty Named Pipe
#94In fish shell the canonical example is this: diff (sort a.txt|psub) (sort b.txt|psub) The psub command performs the process substitution.
Re: The Mighty Named Pipe
#95Earlier quoted context omitted.
That's weird, isn't it? You wanted to know how to use a feature of bash and didn't check the manual?
Do you expect `man python` to output the full reference for the Python programming language?
Re: The Mighty Named Pipe
#96Earlier quoted context omitted.
Be aware that process substitution (and named pipes) can bite you in the arse in some situations --- for example, if the program expects to be able to seek in the file. Pipes don't support this and the program will see it as an I/O error. This'd be fine if programs just errored out cleanly but they frequently don't check that seeking succeeds. unzip treats a named pipe as a corrupt zipfile, for example: $ unzip
Useful. I'm assuming those are cases where normal pipes would fail too? So you can't do: cat z | unzip # I know, uuoc, demo only It's just with the process substitution you have more flexibility to shoot yourself in the foot?
However, if you give a program a filename on a command line, the program's likely to assume it's an actual file.
Re: The Mighty Named Pipe
#97Does anyone have a working link to Gary Bernhardt's The Unix Chainsaw, as mentioned in the article?
Re: The Mighty Named Pipe
#98Earlier quoted context omitted.
Be aware that process substitution (and named pipes) can bite you in the arse in some situations --- for example, if the program expects to be able to seek in the file. Pipes don't support this and the program will see it as an I/O error. This'd be fine if programs just errored out cleanly but they frequently don't check that seeking succeeds. unzip treats a named pipe as a corrupt zipfile, for example: $ unzip
Useful. I'm assuming those are cases where normal pipes would fail too? So you can't do: cat z | unzip # I know, uuoc, demo only It's just with the process substitution you have more flexibility to shoot yourself in the foot?
I wouldn't be surprised if the ZIP file format has its origins outside the Unix world given its pipe-unfriendlyness.
Re: The Mighty Named Pipe
#99Nice article. Really easy to follow introduction. I only discovered process substitution a few months ago but it's already become a frequently used tool in my kit. One thing that I find a little annoying about unix commands sometimes is how hard it can be to google for them. ' Unless you know to look for "Process Substitution" it can be hard to find information on these things. And that's once you even know these thi…
I often use SymbolHound in these cases - it's a search engine with support for special characters; for example: http://symbolhound.com/?q=%3C%28%29