1166: def self::popen cmd, handler=nil, *args
1167: klass = if (handler and handler.is_a?(Class))
1168: raise ArgumentError, 'must provide module or subclass of EventMachine::Connection' unless Connection > handler
1169: handler
1170: else
1171: Class.new( Connection ) {handler and include handler}
1172: end
1173:
1174: w = Shellwords::shellwords( cmd )
1175: w.unshift( w.first ) if w.first
1176: s = invoke_popen( w )
1177: c = klass.new s, *args
1178: @conns[s] = c
1179: yield(c) if block_given?
1180: c
1181: end