Asynchronous tee

I would like to write the same information in two pipes, but I do not want to wait until the first channel reads. Here is an example

mkfifo one
mkfifo two
echo hi | tee one two &
cat one &
cat two &

cat onedoes not start until it is launched cat two. Can I run cat onewithout waiting?

+3
source share
2 answers

Problem: Fifos are blocked until open for reading . So just open the read FD:

mkfifo one two
echo hi | tee one two &
exec 3<one
exec 4<two
cat <&3
cat <&4
+1
source
echo hi | tee one | tee two &
0
source

Source: https://habr.com/ru/post/1744247/


All Articles