Class: Process::Group::Fork

Inherits:
Object
  • Object
show all
Defined in:
lib/process/group.rb

Instance Method Summary collapse

Constructor Details

#initialize(block, options, fiber = Fiber.current) ⇒ Fork

Returns a new instance of Fork.



49
50
51
52
53
54
# File 'lib/process/group.rb', line 49

def initialize(block, options, fiber = Fiber.current)
  @options = options
  @block = block
  
  @fiber = fiber
end

Instance Method Details

#resume(*arguments) ⇒ Object



70
71
72
# File 'lib/process/group.rb', line 70

def resume(*arguments)
  @fiber.resume(*arguments)
end

#run(options = {}) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/process/group.rb', line 56

def run(options = {})
  @pid = Process.fork(&@block)
  
  if options[:pgroup] == true
    # Establishes the child process as a process group leader:
    Process.setpgid(@pid, 0)
  else
    # Set this process as part of the existing process group:
    Process.setpgid(@pid, options[:pgroup])
  end
  
  return @pid
end