Skip to content

Instantly share code, notes, and snippets.

@mrrooijen
Created May 28, 2013 17:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrrooijen/5664317 to your computer and use it in GitHub Desktop.
Save mrrooijen/5664317 to your computer and use it in GitHub Desktop.
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