dspinellis / dgsh

Shell supporting pipelines to and from multiple processes
http://www.spinellis.gr/sw/dgsh/
Other
323 stars 23 forks source link

Consecutive multipipes seem to hang #7

Closed dspinellis closed 7 years ago

dspinellis commented 7 years ago

The following command hangs.

/usr/local/sgsh/bin/bash --sgsh -c '{{ echo a & echo b & }} | cat  | {{ dd of=1 & dd of=2 & }} '
mfragkoulis commented 7 years ago

It's the first time we use dd. So no script was there to wrap it for negotiation.

``

!/usr/local/sgsh/bin/sgsh-wrap /bin/dd

``

Commit 228a3dc fixes this.

dspinellis commented 7 years ago

I had the same problem with

/usr/local/sgsh/bin/bash --sgsh -c '{{ echo a & echo b & }} | cat  | {{ cat >1 & cat >2 & }}

This is why I tried dd.

mfragkoulis commented 7 years ago

OK, that's odd. For me the reference script, which I copy-pasted it from above, runs perfectly fine and I didn't change a thing nor did I issue sudo make install.

dspinellis commented 7 years ago

True. Maybe I run something else.

dspinellis commented 7 years ago

The following fails in the negotiation

[dds@stereo sgsh]$ /usr/local/sgsh/bin/bash --sgsh -c '{{ echo a & echo b & }} | ./sgsh-tee -p 1,2  2>tee.out | {{ cat >1 & cat >2 & }}'
[dds@stereo sgsh]$ tail -1 tee.out
sgsh-tee: sgsh negotiation failed with status code 4
mfragkoulis commented 7 years ago

This is because both cat commands in the last multiple block are flexible while tee -p 1,2 provides precisely two output connections. This topology is not solvable in the general case and therefore the negotiation terminates with an error. The following graph however where dd requires one connection and the other connection is left for cat is perfectly valid:

/usr/local/sgsh/bin/bash --sgsh -c '{{ echo a & echo b & }} | ./sgsh-tee -p 1,2 2>tee.out | {{ dd of=1 & cat >2 & }}'