views:

71

answers:

0

How can I communicate with a process using anonymous pipes in Ruby?

The process in question is supposed to stay there and listen for commands from stdin. I'd also like to read it's output, which is separated by "\r\n".

Using Open3 from the standard library:

@stdin, @stdout, @stderr, @thr = Open3.popen3(cmd)

The problem with this is that the process is started, and then ruby quits, taking the process with it.

How can I keep the process running in a thread in the background while other parts of my program, such as the GUI, run and determine which messages to send to it?