in SmvInterceptor/SmvInterceptor.cs [375:431]
private static int LaunchAndWait(string target, string commandLine, ProcessPriorityClass priority)
{
int exitCode;
// Create the process without a new window and run it transparently through our output
Process p = new Process();
p.StartInfo.CreateNoWindow = true;
p.StartInfo.ErrorDialog = false;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = target;
p.StartInfo.Arguments = Environment.ExpandEnvironmentVariables(commandLine);
p.StartInfo.WorkingDirectory = Environment.CurrentDirectory;
p.StartInfo.UseShellExecute = false;
// Setup the input/output forwarding
p.OutputDataReceived += new DataReceivedEventHandler(
delegate (object sender, DataReceivedEventArgs eventArgs) { Console.WriteLine(eventArgs.Data); }
);
p.ErrorDataReceived += new DataReceivedEventHandler(
delegate (object sender, DataReceivedEventArgs eventArgs) { Console.Error.WriteLine(eventArgs.Data); }
);
try
{
WriteInterceptorLog("LAUNCH: " + p.StartInfo.FileName + " " + p.StartInfo.Arguments);
p.Start();
p.PriorityClass = priority;
p.BeginOutputReadLine();
p.BeginErrorReadLine();
p.WaitForExit();
WriteInterceptorLog("EXIT: " + p.StartInfo.FileName + ". Exit code: " + p.ExitCode);
exitCode = p.ExitCode;
}
catch (Exception e)
{
Console.Error.WriteLine("Failed to launch new executible from interceptor");
Console.Error.WriteLine(e.Message);
Console.Error.WriteLine("target = {0}", target);
Console.Error.WriteLine("command line:");
Console.Error.WriteLine(commandLine);
exitCode = -1;
}
finally
{
p.Close();
}
return exitCode;
}