Beispiel #1
0
        /// <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();
        }
Beispiel #3
0
        /// <inheritdoc />
        public void Start()
        {
            Contract.Requires(!Started, "Process was already started.  Cannot start process more than once.");

            Started = true;
            m_processExecutor.Start();
            ProcessStarted?.Invoke(ProcessId);
        }
Beispiel #4
0
        /// <inheritdoc />
        public virtual void Start()
        {
            Contract.Requires(!Started, "Process was already started.  Cannot start process more than once.");

            CreateAndSetUpProcess();
            m_processExecutor.Start();

            SetProcessStartedExecuting();
        }
Beispiel #5
0
        /// <inheritdoc />
        public void Start()
        {
            Contract.Requires(!Started, "Process was already started.  Cannot start process more than once.");

            SetExecutePermissionIfNeeded(Process.StartInfo.FileName);

            Started = true;
            m_processExecutor.Start();
            ProcessStarted?.Invoke(ProcessId);
        }
Beispiel #6
0
        /// <inheritdoc />
        public void Start()
        {
            Contract.Requires(!Started, "Process was already started.  Cannot start process more than once.");

            m_processExecutor = new AsyncProcessExecutor(
                CreateProcess(),
                ProcessInfo.Timeout ?? TimeSpan.FromMinutes(10),
                line => FeedStdOut(m_output, line),
                line => FeedStdErr(m_error, line),
                ProcessInfo,
                msg => LogProcessState(msg));

            m_processExecutor.Start();

            ProcessStarted?.Invoke();

            ProcessInfo.ProcessIdListener?.Invoke(ProcessId);
        }
 /// <inheritdoc />
 public override void Start()
 {
     Setup();
     m_processExecutor.Start();
 }