Open3.popen3 or Open3.capture3:
Open3 actually just uses Ruby's spawn command, but gives you a much better API.
Open3.popen3
Popen3 runs in a sub-process and returns stdin, stdout, stderr and wait_thr.
require 'open3'
stdin, stdout, stderr, wait_thr = Open3.popen3("sleep 5s && ls&q...