dkogan/feedgnuplot

How to send input to feedgnuplot from a different shell

vapniks opened this issue · 6 comments

If I run feedgnuplot in one of my tmux windows like this:

> feedgnuplot --terminal dumb --exit

I can enter some numbers, and then press Ctrl+d and it will print a graph.
But if instead I trying sending output to its STDIN file descriptor from another shell, e.g:

echo "1\n2\n3\n" > /proc/$(pgrep feedgnuplot)/fd/0

and then pressing Ctrl+d in the feedgnuplot terminal/tmux window, then I get this error:

gnuplot> plot
              ^
         line 0: function to plot expected

If, before pressing Ctrl+d I type print and exit into the feedgnuplot window (directly, not via /proc), like this:

1
2
3
print
enter

then it works, and prints a graph.
But if I try sending those commands along with the data via /proc I get the same error:

echo "1\n2\n3\nprint\nexit" > /proc/$(pgrep feedgnuplot)/fd/0

In the feedgnuplot window:

gnuplot> plot
              ^
         line 0: function to plot expected

What's going on here?
How can I send input to feedgnuplot from a different shell?

Thanks. Actually I have a different problem (trying to pipe output into feedgnuplot via an rlwrap filter), but noticed the previously mentioned behaviour while trying to debug that problem, and wanted to know what's going on.
I've read some stuff about tty's and shells, but I'm still not exactly sure why that behaviour occurs. I guess the tty line driver can somehow differentiate between input received from keypresses and input received from /dev/pty/N, and is only passing on the former to the shell process, or is it something feedgnuplot is doing?

No, I'm not wrapping feedgnuplot, I'm wrapping another repl and trying to pipe the output to feedgnuplot using a filter I wrote.
The piping seems to work fine with other shell commands, but when I try to pipe a list of numbers to feedgnuplot it just hangs and I have to SIGKILL it. I'm trying to figure out what's going on.

Guess I'll have to strace it.