IntPtr stderr,
ref ProcInfo proc_info);
- private static bool Start_shell (ProcessStartInfo startInfo,
- Process process)
+ private static bool Start_shell (ProcessStartInfo startInfo, Process process)
{
ProcInfo proc_info=new ProcInfo();
bool ret;
process.process_handle = proc_info.process_handle;
process.pid = proc_info.pid;
-
process.StartExitCallbackIfNeeded ();
-
return(ret);
}
if (startInfo == null)
throw new ArgumentNullException ("startInfo");
- Process process=new Process();
+ Process process = new Process();
process.StartInfo = startInfo;
- if (Start_common(startInfo, process))
+ if (Start_common(startInfo, process) && process.process_handle != IntPtr.Zero)
return process;
return null;
}
[ComVisibleAttribute(false)]
public void CancelErrorRead ()
{
- if (process_handle == IntPtr.Zero || output_stream == null || StartInfo.RedirectStandardOutput == false)
- throw new InvalidOperationException ("Standard output has not been redirected or process has not been started.");
+ if (process_handle == IntPtr.Zero || error_stream == null || StartInfo.RedirectStandardError == false)
+ throw new InvalidOperationException ("Standard error has not been redirected or process has not been started.");
if ((async_mode & AsyncModes.SyncOutput) != 0)
throw new InvalidOperationException ("OutputStream is not enabled for asynchronous read operations.");
async_output.Close ();
if (async_error != null)
async_error.Close ();
+
+ if (input_stream != null) {
+ input_stream.Close();
+ input_stream = null;
+ }
+
+ if (output_stream != null) {
+ output_stream.Close();
+ output_stream = null;
+ }
+
+ if (error_stream != null) {
+ error_stream.Close();
+ error_stream = null;
+ }
}
}
Process_free_internal(process_handle);
process_handle=IntPtr.Zero;
}
-
- if (input_stream != null) {
- input_stream.Close();
- input_stream = null;
- }
-
- if (output_stream != null) {
- output_stream.Close();
- output_stream = null;
- }
-
- if (error_stream != null) {
- error_stream.Close();
- error_stream = null;
- }
}
}
base.Dispose (disposing);