# File lib/deep_test/warlock.rb, line 9
 9:     def start(name, &block)
10:       # Not synchronizing for the fork seems to cause
11:       # random errors (Bus Error, Segfault, and GC non-object)
12:       # in RemoteWorkerServer processes.
13:       #
14:       begin
15:         pid = nil
16:         @demons_semaphore.synchronize do 
17:           pid = DeepTest.drb_safe_fork do
18:             # Fork leaves the semaphore locked and we'll never make it
19:             # to end of synchronize block.
20:             #
21:             # The Ruby 1.8.6 C mutex implementation automatically treats
22:             # a mutex locked by a dead thread as unlocked and will raise
23:             # an error if we try to unlock it from this thread.
24:             #
25:             @demons_semaphore.unlock if @demons_semaphore.locked?
26: 
27:             begin
28:               yield
29:             rescue Exception => e
30:               DeepTest.logger.debug "Exception in #{name} (#{Process.pid}): #{e.message}"
31:               raise
32:             end
33: 
34:             exit
35:           end
36: 
37:           raise "fatal: fork returned nil" if pid.nil?
38:           add_demon name, pid
39:         end
40: 
41:         launch_reaper_thread name, pid
42: 
43:       rescue => e
44:         puts "exception starting #{name}: #{e}"
45:         puts "\t" + e.backtrace.join("\n\t")
46:       end
47:     end