How to setup a pipe to a long running process?

Please learn to use markdown code blocks and preserve indentation while copy pasting code. Your code posts tend to be really hard to read.

Process.run with a block sets up pipes for you by default:

Process.run("ls", args: {"/"}) do |proc|
  puts proc.output.gets
end

If you set them explicitly, Process does not bother to retain a reference to them, you passed one in, so you got it already! Just reuse your writer variable.