我有一些像这样的shell代码:
rm -f myfifo && mkfifo myfifo
(
echo "data1" > myfifo
echo "wrote first"
echo "data2" > myfifo
echo "wrote second"
) &
read -r ONE <myfifo
echo "$ONE"
read -r TWO <myfifo
echo "$TWO"
我希望我会得到以下输出:
wrote first
data1
wrote second
data2
但是我得到以下输出:
wrote first
wrote second
data1
然后它永远挂起。 关于命名管道,我不了解什么原则?
谢谢。