如何使我的仅阅读流媒体流非缓冲?
据我所知,调用shell命令和读取其输出的建议方法是通过popen
(例如,这个答案)。但是,popen(3)
的人页面说:
Note that output popen() streams are block buffered by default.
如何使我的只读管道非缓冲?
例如:
FILE* ro_pipe = popen("echo hello", "r");
不会填写4KB输出缓冲区,但是我想在将其写入Shell命令的Stdout后立即准备好读取。
As far as I can tell, the advised method of calling a shell command and reading its output is via popen
(e.g., this answer). However, the man page for popen(3)
says:
Note that output popen() streams are block buffered by default.
How do I make my read-only pipe non-buffered?
For example:
FILE* ro_pipe = popen("echo hello", "r");
won't fill out the 4KB output buffer, but I'd want to have the output data ready to read as soon as it is written to the stdout of the shell command.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论