linux - 在 Linux 下将程序的输出流式传输到任意数量的程序?

标签 linux streaming

我应该如何将一个程序的输出流式传输到未定义数量的程序,以便数据不会在任何地方缓冲,并且即使没有任何内容读取流,流的来源应用程序也不会阻塞,但是如果第一个提到的程序没有输出,读取流的程序会阻塞吗?

我已经尝试用 Google 搜索了一段时间,但我所找到的只是在没有任何内容读取流时程序确实会阻塞的方法。

最佳答案

How should I stream the output from one program to an undefined number of programs in such a fashion that the data isn't buffered anywhere and that the application where the stream originates from doesn't block even if there's nothing reading the stream

如果没有某种形式的缓冲区,您的要求就不可能得到满足。

最直接的选择是将输出写入文件并让消费者读取该文件。

另一种选择是使用内存映射文件形式的环形缓冲区。由于环形缓冲区的容量通常是固定的,因此需要制定处理慢速消费者的政策。选项是:阻止生产者;终止慢速消费者;让缓慢的消费者在丢失数据时以某种方式恢复。

关于linux - 在 Linux 下将程序的输出流式传输到任意数量的程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14051629/

相关文章:

.net - WCF 流和恢复选项

streaming - 如何使用 `m4v` 将视频转换为 `ffmpeg` ?

c++ - 是否有任何将资源嵌入 Linux 可执行镜像的标准方法?

arrays - 将 2 个数组与总和值进行比较

php - 自定义 cron 作业未安排 Magento2

c++ - 如果我不关闭,ifstream 会导致内存泄漏吗?

linux - 使用 shell 脚本杀死 vim 进程会留下 .swp 文件

ruby-on-rails - rails : on-the-fly streaming of output in zip format?

node.js - http.request 的响应如何在两个可写流的幕后工作?

video-streaming - 当有数千个 SRS 实例时如何配置同事