379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
|
# File 'lib/open4.rb', line 379
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
|