Class: Process::Group::Fork
Overview
Runs a given block using a forked process.
Instance Attribute Summary
Attributes inherited from Command
Instance Method Summary collapse
- #call(**options) ⇒ Object
-
#initialize(block, **options) ⇒ Fork
constructor
A new instance of Fork.
- #resume(*arguments) ⇒ Object
Methods inherited from Command
Constructor Details
#initialize(block, **options) ⇒ Fork
Returns a new instance of Fork.
78 79 80 81 82 |
# File 'lib/process/group.rb', line 78 def initialize(block, **) @block = block super(**) end |
Instance Method Details
#call(**options) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/process/group.rb', line 84 def call(**) = @options.merge() @pid = Process.fork(&@block) if [:pgroup] == true # Establishes the child process as a process group leader: Process.setpgid(@pid, 0) elsif pgroup = [:pgroup] # Set this process as part of the existing process group: Process.setpgid(@pid, pgroup) end return @pid end |
#resume(*arguments) ⇒ Object
100 101 102 |
# File 'lib/process/group.rb', line 100 def resume(*arguments) @fiber.resume(*arguments) end |