Class: SweetPi::Fork

Inherits:
Object
  • Object
show all
Defined in:
lib/sweet_pi/fork.rb

Instance Method Summary collapse

Constructor Details

#initialize(*argv, &block) ⇒ Fork

Returns a new instance of Fork.



6
7
8
9
10
11
# File 'lib/sweet_pi/fork.rb', line 6

def initialize(*argv, &block)
  @status_read, @status_write = IO.pipe
  @value_read, @value_write = IO.pipe

  child_fork(*argv, block)
end

Instance Method Details

#valueObject



13
14
15
16
# File 'lib/sweet_pi/fork.rb', line 13

def value
  Process.waitpid @pid
  Marshal.load(@value_read)
end