Module: Process

Defined in:
lib/process_shared/mach.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.forkObject

Override to first copy all shared ports (semaphores, etc.) from parent process to child process.


66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/process_shared/mach.rb', line 66

def fork
  # make a port for receiving message from child
  port = Mach::Port.new
  port.insert_right(:make_send)
  Mach::Task.self.set_bootstrap_port(port)
  
  if block_given?
    pid = __mach_original_fork__ do
      ProcessShared::Mach.after_fork_child
      yield
    end

    ProcessShared::Mach.after_fork_parent(port)
    pid
  else
    if pid = __mach_original_fork__
      ProcessShared::Mach.after_fork_parent(port)
      pid
    else
      ProcessShared::Mach.after_fork_child
      nil
    end
  end
end

Instance Method Details

#__mach_original_fork__Object


61
# File 'lib/process_shared/mach.rb', line 61

alias_method :__mach_original_fork__, :fork