Module: Specjour::Fork

Included in:
Loader, Manager
Defined in:
lib/specjour/fork.rb

Class Method Summary collapse

Class Method Details

.forkObject

fork, but don’t run the parent’s exit handlers The one exit handler we lose however, is the printing out of exceptions, so reincorporate that.



8
9
10
11
12
13
14
15
16
17
# File 'lib/specjour/fork.rb', line 8

def fork
  Kernel.fork do
    at_exit { exit! }
    begin
      yield
    rescue StandardError => e
      $stderr.puts "#{e.class} #{e.message}", e.backtrace
    end
  end
end

.fork_quietlyObject



19
20
21
22
23
24
# File 'lib/specjour/fork.rb', line 19

def fork_quietly
  fork do
    $stdout = StringIO.new
    yield
  end
end