Created
May 28, 2013 17:05
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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