Avoiding `readavailable()` when communicating with long-lived external program

For simplicity/readability purposes, you might just want startgp() to return just “process”. (::Process objects already have all 3 streams as parameters).

The problem was that they weren’t available to process::Process when you specified them in the pipeline(`gnuplot`, stdin=inp, stdout=out, stderr=err) command. Good news though: they get transferred properly when they are specified in the call to run() instead.

STDIN

In fact:

println(process, "exit gnuplot")

sends "exit gnuplot" it to gnuplot’s STDIN (forwards println() to process.in).

STDOUT

And:

nextline = readline(process)

forwards the readline() command to process.out.

STDERR

Though to get data out of STDERR, you need to be a bit more explicit:

nextline = readline(process.err)
1 Like