@JRubyMethod(name = "pipe", meta = true)
public static IRubyObject pipe(ThreadContext context, IRubyObject recv) {
// TODO: This isn't an exact port of MRI's pipe behavior, so revisit
Ruby runtime = context.getRuntime();
try {
Pipe pipe = Pipe.open();
RubyIO source = new RubyIO(runtime, pipe.source());
RubyIO sink = new RubyIO(runtime, pipe.sink());
sink.openFile.getMainStreamSafe().setSync(true);
return runtime.newArrayNoCopy(new IRubyObject[]{source, sink});
} catch (BadDescriptorException e) {
throw runtime.newErrnoEBADFError();