Skip to content

Instantly share code, notes, and snippets.

@headius
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save headius/acb0f91fe03a1f5df730 to your computer and use it in GitHub Desktop.
Save headius/acb0f91fe03a1f5df730 to your computer and use it in GitHub Desktop.
FINALLY, real UNIX-style process mgmt on JRuby
system ~/projects/jruby $ cat blah.rb
in_c, in_p = IO.pipe
out_p, out_c = IO.pipe
err_p, err_c = IO.pipe
pid = spawn('cat', :in => in_c, :out => out_c, :err => err_c)
[in_c, out_c, err_c].each(&:close)
in_p.puts("hello, world")
in_p.close
puts out_p.read
Process.waitpid(pid)
system ~/projects/jruby $ jruby blah.rb
hello, world
in_c, in_p = IO.pipe
out_p, out_c = IO.pipe
err_p, err_c = IO.pipe
pid = spawn('cat -n',
:in => in_c,
:out => out_c,
:err => err_c)
[in_c, out_c, err_c].each(&:close)
in_p.puts("hello, world")
in_p.close
puts out_p.read # => " 1 hello, world"
Process.waitpid(pid)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment