When designing a chain of commands to perform a certain task, i ran into the problem that anonymous pipes do not behave like expected. As the original command that i am running
Whe you use <( ... )
for process substitution, the process running inside does not have a controlling terminal. But pv
always shows its results to the terminal; if there isn't any, it gets stopped.
If you execute your code and, while it is running, do a ps axf
, you will see something like this:
23412 pts/16 S 0:00 \_ bash
24255 pts/16 S+ 0:00 \_ cat /dev/zero
24256 pts/16 S+ 0:00 \_ tee /dev/fd/63
24258 pts/16 S 0:00 | \_ bash
24259 pts/16 T 0:00 | \_ pv -c
24257 pts/16 S+ 0:00 \_ pv -c
...which tells you that the pv -c
executed inside the process substitution (the one below the second bash
) is in T
state, stopped. It is waiting to have a controlling terminal in order to run. It does not have any, so it will stop forever, and bash
eventually stops sending data to that pipe.