Skip to content

Instantly share code, notes, and snippets.

@jamesmartin
Created May 4, 2015 06:21
Show Gist options
  • Select an option

  • Save jamesmartin/082ae55cf8458384b980 to your computer and use it in GitHub Desktop.

Select an option

Save jamesmartin/082ae55cf8458384b980 to your computer and use it in GitHub Desktop.
Fork/exec a sub process, wait for it to rejoin and then print the status
# Runs exec inside the fork in order to capture the output of the subprocess
pid = fork { exec('ssh 127.0.0.1') }
_, status = Process.waitpid2(pid)
puts status.success?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment