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.
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.
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.
¿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: 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).