public static RubyIO /*!*/ OpenPipe(RubyContext /*!*/ context, RubyClass /*!*/ self, [DefaultProtocol, NotNull] MutableString /*!*/ command, [DefaultProtocol, Optional, NotNull] MutableString modeString) { bool preserveEndOfLines; IOMode mode = RubyIO.ParseIOMode(modeString.ConvertToString(), out preserveEndOfLines); ProcessStartInfo startInfo = KernelOps.GetShell(context, command); startInfo.UseShellExecute = false; if (mode == IOMode.ReadOnlyFromStart) { startInfo.RedirectStandardOutput = true; } else if (mode == IOMode.WriteOnlyAppend || mode == IOMode.WriteOnlyTruncate) { startInfo.RedirectStandardInput = true; } else { startInfo.RedirectStandardOutput = true; startInfo.RedirectStandardInput = true; } Process process; try { process = Process.Start(startInfo); } catch (Exception e) { throw new Errno.NoEntryError(startInfo.FileName, e); } context.ChildProcessExitStatus = new RubyProcess.Status(process); StreamReader reader = null; StreamWriter writer = null; if (startInfo.RedirectStandardOutput) { reader = process.StandardOutput; } if (startInfo.RedirectStandardInput) { writer = process.StandardInput; } return(new RubyIO(context, reader, writer, modeString.ConvertToString())); }