Skip to content

Instantly share code, notes, and snippets.

@mrrooijen

mrrooijen/run.rb

Created May 28, 2013
Embed
What would you like to do?
Quick `open3` wrapper for running a synchronous system command and returning the pid, exit_status, stdout and stderr of the provided command.
require "open3"
def run(cmd)
Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
return {
pid: wait_thr.pid,
exit_status: wait_thr.value.to_i,
stdout: stdout.read,
stderr: stderr.read
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment