Module: EventMachine

Defined in:
lib/slinky/em-popen3.rb

Defined Under Namespace

Classes: Popen3StderrHandler

Class Method Summary collapse

Class Method Details

.popen3(*args) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/slinky/em-popen3.rb', line 16

def self.popen3(*args)
  new_stderr = $stderr.dup
  rd, wr = IO::pipe
  $stderr.reopen wr
  connection = EM.popen(*args)
  $stderr.reopen new_stderr
  EM.attach rd, Popen3StderrHandler, connection
  connection
end

.system3(cmd, *args, &cb) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
# File 'lib/slinky/em-popen3.rb', line 57

def EventMachine::system3 cmd, *args, &cb
  cb ||= args.pop if args.last.is_a? Proc
  init = args.pop if args.last.is_a? Proc

  # merge remaining arguments into the command
  cmd = ([cmd] + args.map{|a|a.to_s.dump}).join(' ')

  EM.get_subprocess_pid(EM.popen3(cmd, ProcessHandler, cb) do |c|
                          init[c] if init
                        end.signature)
end