Skip to content

Instantly share code, notes, and snippets.

@nmarley
Created April 15, 2013 02:13
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 nmarley/5385219 to your computer and use it in GitHub Desktop.
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.
#!/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