bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

process substitution flawed by design


From: Florian Mayer
Subject: process substitution flawed by design
Date: Mon, 20 Feb 2017 23:25:22 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0

echo foo | tee >(echo $$) >(echo $$) >/dev/null | cat

returns the same PID twice. I'm using the version 4.4.11.
Why is there only one process for all the expansions?
Why wasn't that documented?

I think the only right way to do multiple process expansions in one command
is by actually starting one process for each expansion.

Why doesn't this workaround work? It produces the same output as the first snippet
echo foo | tee >((echo $$)) >((echo $$)) >/dev/null | cat

You might now be wondering why I'm saying that it is wrong to
execute everything in one process. Consider the following:

cat some file | tee \
    >(mutex --lock; critical; mutex --unlock) \
    >(mutex --lock; critical; mutex --unlock) \
    > /dev/null | cat


What I'd wish for is that both >() blocks get the same input by tee and produce some synchronized output.
That is also the most natural way to think about this expansion.
GNU parallel allows for something like mutex --lock by the way.

There are problems that'd require for something like the above.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]