Method: Open4.bg

Defined in:
lib/crazy_ivan/vendor/open4-1.0.1/lib/open4.rb

.bgObject

–}}}



357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
# File 'lib/crazy_ivan/vendor/open4-1.0.1/lib/open4.rb', line 357

def background arg, *argv 
#--{{{

  require 'thread'
  q = Queue.new
  opts = { 'pid' => q, :pid => q }
  case argv.last
    when Hash
      argv.last.update opts
    else
      argv.push opts
  end
  thread = Thread.new(arg, argv){|arg, argv| spawn arg, *argv}
  sc = class << thread; self; end
  sc.module_eval {
    define_method(:pid){ @pid ||= q.pop }
    define_method(:spawn_status){ @spawn_status ||= value }
    define_method(:exitstatus){ @exitstatus ||= spawn_status.exitstatus }
  }
  thread
#--}}}

end