我是 Bash 脚本编程的新手,我正在尝试理解以下代码:
tmp_file=/tmp/tmp_file$$
mkfifo $tmp_file
echo "msg_A" >$tmp_file # blocks, since pipe is unbuffered and no one is reading from it
read msg <$tmp_file
echo $msg
tmp_file=/tmp/tmp_file$$
mkfifo $tmp_file
exec 7<>$tmp_file # add this line
echo "msg_A" >$tmp_file # now, the write operation won't block, why?
read msg <$tmp_file
echo $msg # msg_A is printed
我想知道exec 7<>$tmp_file
上面的代码示例中做了什么,以及为什么添加此行会使写入操作非阻塞?