How to create a non-blocking system call in Ruby?

I want to make a system call in ruby, but instead of waiting for the process to complete, I want my script to continue to work.

What is the recommended way to handle this?

+4
source share
2 answers

You can use Process.spawn .

Once the process is created, you can either wait for the process to complete (using waitpid ) or detach .

+9
source

See IO#popen in the standard library.

 f = IO.popen("date") f.gets # => "Wed Aug 10 14:56:59 MDT 2011\n" f.close 
+4
source

All Articles