T形管异步 [英] Tee a Pipe Asynchronously

查看:100
本文介绍了T形管异步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想同样的信息写入到两个管道,但我不希望等待第一管阅读。这里有一个例子

I would like to write the same information to two pipes, but I don't want to wait for the first pipe to read. Here's an example


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

猫有一个不开始读,直到猫两个运行。有没有一种方法,使猫有一个运行,而无需等待?

cat one does not start reading until cat two is run. Is there a way to make cat one run without waiting?

推荐答案

问题:FIFO都阻塞,直到打开阅读即可。所以,只要打开一个读FD他们:

Problem: Fifos are blocking until opened for reading. So just open a read FD on them:

mkfifo one two
echo hi | tee one two &
exec 3<one
exec 4<two
cat <&3
cat <&4

这篇关于T形管异步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆