如何在没有缓冲区的情况下保存tty?
我在缓冲区方面遇到了麻烦:
我有一个守护进程 D 和它的监视器 M。 D 在 M 之前启动,M 将任何相关信息打印到 tty,我需要解析这些信息并将其提供给我自己的程序。
由于我想自动执行此操作,因此 M 应该打印到文件。但直到守护进程因为缓冲区而被杀死时才会发生。
所以我正在考虑记录 tty,因此尝试使用脚本将输出记录到终端,但是......它也被缓冲......
我还尝试访问 gnu coreutils (以利用我显然需要的 stdbuf )但当我无法安装该实用程序来解压缩 GNU 网站上建议的特殊 .xz 格式时,我不得不放弃!
我担心我什至没有做正确的事! 难道没有一个简单的解决方案可以解决这个问题,每个使用实时技术的人都可能已经遇到过吗?
如果有一点帮助,我们将不胜感激。谢谢。
I'm having trouble with buffers :
I have a daemon D, and its monitor M.
D is started before M, and M prints any relevant information to the tty, and I need to parse this information and give it to a program of my own.
Since I want to automate this, M should print to a file. But it doesn't until the daemon has been killed, because of buffers.
So I was thinking of recording the tty and therefore tried to use script to record the output to the terminal but ... it's buffered also ...
I also tried getting access to the gnu coreutils (to make use of stdbuf which I apparently need) but had to give up when I couldn't install the utility to unzip the peculiar .xz format proposed on GNU's website !
I fear I'm not even doing the right thing !
Isn't there a simple solution to this problem that potentially everyone who works with real-time has had ??
A little help would be much appreciated. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
xz
或7zip
此页面是我关于 stdio 缓冲的首选参考:http://www.pixelbeat.org/programming/stdio_buffering/
PS。 “每个使用实时工作的人”大概都使用 IPC 并且不依赖 bash。 Perl、Python 以及显然所有低级语言都提供了显式禁用/启用缓冲的方法
xz
or7zip
This page is my preferred reference on stdio buffering: http://www.pixelbeat.org/programming/stdio_buffering/
PS. 'everyone who works with real-time' presumably uses IPC and doesn't rely on bash. Perl, python and obviously all lower-level languages provide ways to explicitely disable/enable buffering