Re: process substitution flawed by design

2017-02-21 Thread Chet Ramey
On 2/21/17 8:18 AM, Florian Mayer wrote: > The following code assumes the lock to be in state not-taken before the > snippet runs. > > echo foo | tee \ > >(mutex --lock; echo before; cat; echo after; mutex --unlock) \ > >(mutex --lock; echo foobar; mutex --unlock) \ > > /dev/null | ca

Re: process substitution flawed by design

2017-02-21 Thread Greg Wooledge
On Tue, Feb 21, 2017 at 03:11:22PM +0100, Florian Mayer wrote: > >What does it do? > It behaves like the p-operation on unary Sys-V semaphores. OK, without digging any further into this morass, and without trying to guess whether you've found a bug in bash or in your own tool, can I just leave thi

Re: process substitution flawed by design

2017-02-21 Thread Pierre Gaston
On Tue, Feb 21, 2017 at 3:18 PM, Florian Mayer wrote: > The following code assumes the lock to be in state not-taken before the > snippet runs. > > echo foo | tee \ > >(mutex --lock; echo before; cat; echo after; mutex --unlock) \ > >(mutex --lock; echo foobar; mutex --unlock) \ > >

Re: process substitution flawed by design

2017-02-21 Thread Florian Mayer
What does it do? It behaves like the p-operation on unary Sys-V semaphores. If the semaphore has not been taken (has had the value 1), mutex --lock immediately exits. If the semaphore has indeed been taken already (has the value 0), mutex --lock will try to gain the lock and only exit if it wa

Re: process substitution flawed by design

2017-02-21 Thread Pierre Gaston
On Tue, Feb 21, 2017 at 4:00 PM, Pierre Gaston wrote: > > > On Tue, Feb 21, 2017 at 3:18 PM, Florian Mayer > wrote: > >> The following code assumes the lock to be in state not-taken before the >> snippet runs. >> >> echo foo | tee \ >> >(mutex --lock; echo before; cat; echo after; mutex --u

Re: process substitution flawed by design

2017-02-21 Thread Greg Wooledge
On Tue, Feb 21, 2017 at 02:18:03PM +0100, Florian Mayer wrote: > for mutex --lock I use a tool which I wrote myself. What does it do? > The following code assumes the lock to be in state not-taken before the > snippet runs. What lock? > echo foo | tee \ > >(mutex --lock; echo before; cat;

Re: process substitution flawed by design

2017-02-21 Thread Florian Mayer
The following code assumes the lock to be in state not-taken before the snippet runs. echo foo | tee \ >(mutex --lock; echo before; cat; echo after; mutex --unlock) \ >(mutex --lock; echo foobar; mutex --unlock) \ > /dev/null | cat for mutex --lock I use a tool which I wrote myself

Re: process substitution flawed by design

2017-02-20 Thread Greg Wooledge
On Mon, Feb 20, 2017 at 11:25:22PM +0100, Florian Mayer wrote: > echo foo | tee >(echo $$) >(echo $$) >/dev/null | cat > > returns the same PID twice. $$ is the PID of the main shell. I think what you want is the PID of each subshell, $BASHPID. imadev:~$ cat <(echo $$) <(echo $$) 3751 3751 imad

process substitution flawed by design

2017-02-20 Thread Florian Mayer
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 o