Created
April 15, 2013 02:13
-
-
Save nmarley/5385219 to your computer and use it in GitHub Desktop.
Ruby function which runs a command and WAITS for it to finish before continuing processing.
This file contains 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
#!/usr/bin/env ruby | |
def runcmd(cmd) | |
pid = Process.spawn(cmd) | |
Process.wait(pid) | |
unless ( $?.exited? && $?.exitstatus == 0 ) | |
raise "oh noes" | |
end | |
$?.exitstatus | |
end | |
cmd = "sleep 3" | |
runcmd(cmd) | |
puts "Hi, world!" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment