/// <inheritdoc /> public override void Start() { base.Start(); SerializeSandboxedProcessInfoToFile(); var process = new Process { StartInfo = new ProcessStartInfo { FileName = m_tool.ExecutablePath, Arguments = m_tool.CreateArguments(SandboxedProcessInfoFile, SandboxedProcessResultsFile), WorkingDirectory = SandboxedProcessInfo.WorkingDirectory, RedirectStandardError = true, RedirectStandardOutput = true, UseShellExecute = false, CreateNoWindow = true }, EnableRaisingEvents = true }; m_processExecutor = new AsyncProcessExecutor( process, TimeSpan.FromMilliseconds(-1), // Timeout should only be applied to the process that the external tool executes. line => AppendLineIfNotNull(m_output, line), line => AppendLineIfNotNull(m_error, line), SandboxedProcessInfo.Provenance, message => LogExternalExecution(message)); m_processExecutor.Start(); }
private void RunInVm() { // (1) Serialize sandboxed prosess info. SerializeSandboxedProcessInfoToFile(); // (2) Create and serialize run request. var runRequest = new RunRequest { AbsolutePath = m_tool.ExecutablePath, Arguments = m_tool.CreateArguments(GetSandboxedProcessInfoFile(), GetSandboxedProcessResultsFile()), WorkingDirectory = GetOutputDirectory() }; VmSerializer.SerializeToFile(RunRequestPath, runRequest); // (2) Create a process to execute VmCommandProxy. string arguments = $"{VmCommands.Run} /{VmCommands.Params.InputJsonFile}:\"{RunRequestPath}\" /{VmCommands.Params.OutputJsonFile}:\"{RunOutputPath}\""; var process = CreateVmCommandProxyProcess(arguments); LogExternalExecution($"call (wd: {process.StartInfo.WorkingDirectory}) {m_vmInitializer.VmCommandProxy} {arguments}"); m_processExecutor = new AsyncProcessExecutor( process, TimeSpan.FromMilliseconds(-1), // Timeout should only be applied to the process that the external tool executes. line => AppendLineIfNotNull(m_output, line), line => AppendLineIfNotNull(m_error, line), SandboxedProcessInfo.Provenance, message => LogExternalExecution(message)); m_processExecutor.Start(); }