在不关闭管道的情况下在管道中发送EOF [英] Send a EOF in a pipe without closing it

查看:206
本文介绍了在不关闭管道的情况下在管道中发送EOF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个使用GnuPlot绘制数据的应用程序. 我决定使用二进制"格式,而不是使用文本格式通过管道来通信这两个程序(这很慢,因为vprintf()和大量数据正在传递).

I am writing an app which uses GnuPlot for ploting data. Instead of using text format to comunicate both programs though a pipe (it is slow because of the vprintf() and the big amount of data being passed) I decided to use "binary" format.

问题在于,二进制格式的GnuPlot期望EOF(Ctrl + D)结束传输并绘制数据.在UNIX控制台模式下,这很容易.只需按Ctrl + D即可结束数据输入,绘制数据并保持控制台打开以等待更多命令.

The problem is that in binary format GnuPlot expects a EOF (Ctrl+D) to end the transmission and plot the data. This is easy in UNIX console mode. Just pressing Ctrl+D will end the data input, plot the data AND mantain the console open waiting for more commands.

但是在我的C ++应用程序中,发送EOF的唯一方法是关闭管道.这将导致gnuplot进程终止,并且不会在屏幕上显示该图.

But in my C++ app the only way to send a EOF is to close the pipe. This causes the gnuplot process to die and does not show the plot to the screen.

¿是否有一些技巧可以将EOF发送到管道? ¿UNIX终端如何在不关闭正在运行的进程的情况下发送EOF的情况下进行管理?

¿Is there some trick to send a EOF to a pipe? ¿How does the UNIX terminal manage to send a EOF without closing its pipe with the running process?

PD:我无法使用"-persist"关闭并重新打开GnuPlot,因为它会生成一个新图而不是更新旧图(这是一个实时系统,因此它会生成〜inf图窗口).

PD: I can't close and reopen GnuPlot with "-persist", because that generates a NEW plot instead of updating the old plot (it is a real time system so it generates near ~inf plot windows).

推荐答案

我认为您要执行的操作无效.参见例如:

I don't think what you want to do will work. See for example:

http://www.velocityreviews.com/forums /t365339-write-eof-without-closing.html

我们可以自己写一个EOF字符吗?

基本上,EOF本身不是字符.这是文件的结尾.

Basically EOF is no character per se. It's the end of the file.

因此,正如我在上面的评论中指出的那样,建议您尝试使用直接将您连接到gnuplot的库.然后,您应该能够控制它,以实现所需的行为(最有可能使用replot之类的东西).

So as I noted in the comment above I suggest you try using a library which connects you directly to gnuplot. Then you should be able to control it such that your desired behaviour is achieved (most likely using something like replot).

这篇关于在不关闭管道的情况下在管道中发送EOF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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