Like ChildProcess but forks instead of creating new process. In certain cases (e.g, child code shares heavy initialization with parent; like ActiveRecord, etc.) should perform better than ChildProcess. On the flip side, it does not work on Windows and Jruby.
The main difference from plain Process.fork
is that this one is guaranteed to not outlive parent process. Plus it implements some of ChildProcess api, so that those two can be hidden behind common interface.
Usage:
# Gemfile
gem 'child_fork', git: 'git://gist.github.com/1927233.git'
# code
require 'child_fork'
child = ChildFork.new do
LongAndPainfulJob.new
end
child.alive? # true
child.stop # force stop
Install the rspec gem
gem install rspec
Run the spec
rspec child_fork_spec.rb