+ //
+ // Creates read/write pipe from parent -> child perspective
+ // a child process uses same descriptors after fork. That's
+ // 4 descriptors in total where only 2. One in child, one in parent
+ // should be active and the other 2 closed. Which ones depends on
+ // comunication direction
+ //
+ // parent --------> child (parent can write, child can read)
+ //
+ // read: closed read: used
+ // write: used write: closed
+ //
+ //
+ // parent <-------- child (parent can read, child can write)
+ //
+ // read: used read: closed
+ // write: closed write: used
+ //
+ // It can still be tricky for predefined descriptiors http://unixwiz.net/techtips/remap-pipe-fds.html
+ //
+ if (!MonoIO.CreatePipe (out read, out write, out error))
+ throw MonoIO.GetException (error);
+
+ if (IsWindows) {
+ const int DUPLICATE_SAME_ACCESS = 0x00000002;
+ var tmp = writeDirection ? write : read;
+
+ if (!MonoIO.DuplicateHandle (Process.GetCurrentProcess ().Handle, tmp, Process.GetCurrentProcess ().Handle, out tmp, 0, 0, DUPLICATE_SAME_ACCESS, out error))
+ throw MonoIO.GetException (error);
+
+ if (writeDirection) {
+ if (!MonoIO.Close (write, out error))
+ throw MonoIO.GetException (error);
+ write = tmp;
+ } else {
+ if (!MonoIO.Close (read, out error))
+ throw MonoIO.GetException (error);
+ read = tmp;
+ }
+ }
+ }
+
+ static bool Start_noshell (ProcessStartInfo startInfo, Process process)
+ {
+ var proc_info = new ProcInfo ();
+