Skip to content

Synchronization

mosop edited this page Nov 26, 2016 · 7 revisions

Commands are run asynchronously in forked processes. For example, the following code is wrong.

process = Run::Command.new("sleep", %w(100)).run
# no wait
puts "100 seconds elapsed."

To synchronize with running processes, use the process object's #wait method.

process = Run::Command.new("sleep", %w(100)).run
process.wait
puts "100 seconds elapsed."
Clone this wiki locally