IntPtr stderr,
ref ProcInfo proc_info);
- private static bool Start_shell (ProcessStartInfo startInfo)
+ private static bool Start_shell (ProcessStartInfo startInfo, Process process)
{
ProcInfo proc_info=new ProcInfo();
bool ret;
throw new Win32Exception (-proc_info.pid);
}
+ process.process_handle = proc_info.process_handle;
+ process.pid = proc_info.pid;
+ process.StartExitCallbackIfNeeded ();
return(ret);
}
if (startInfo.UseShellExecute) {
if (!String.IsNullOrEmpty (startInfo.UserName))
throw new InvalidOperationException ("UserShellExecute must be false if an explicit UserName is specified when starting a process");
- return (Start_shell (startInfo));
+ return (Start_shell (startInfo, process));
} else {
return (Start_noshell (startInfo, process));
}
if (startInfo == null)
throw new ArgumentNullException ("startInfo");
- Process process = null;
- if (!startInfo.UseShellExecute) {
- process = new Process();
- process.StartInfo = startInfo;
- }
- if (Start_common(startInfo, process))
+ Process process = new Process();
+ process.StartInfo = startInfo;
+ 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.");