internal static void TearDownOutputRedirection (SafeFileHandle outReadPipe, SafeFileHandle errorReadPipe, STARTUPINFO si, CorProcess ret) { if (outReadPipe != null) { // Close pipe handles (do not continue to modify the parent). // You need to make sure that no handles to the write end of the // output pipe are maintained in this process or else the pipe will // not close when the child process exits and the ReadFile will hang. si.hStdInput.Close (); si.hStdOutput.Close (); si.hStdError.Close (); ret.TrackStdOutput (outReadPipe, errorReadPipe); } }