How do you spawn a child process in Ruby?

前端 未结 5 447
南旧
南旧 2020-12-13 12:54

I want to offload a block of code in my main process to child process to make it run concurrently. I also want to have the PID of the spawned child process so I can monitor

5条回答
  •  别那么骄傲
    2020-12-13 13:38

    A good alternative to fork/exec/spawn is the posix-spawn gem for Ruby 1.9: https://github.com/rtomayko/posix-spawn

    They did most of the hard work to make it easier, efficient, and flexible compared to the lower level methods.

提交回复
热议问题