Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-09 08:30:26

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include <boost/process.hpp>
0012 #include <boost/process/environment.hpp>
0013 #include <boost/process/process.hpp>
0014 #include <boost/process/start_dir.hpp>
0015 #include <boost/process/stdio.hpp>
0016 
0017 namespace ActsPlugins::detail {
0018 
0019 // With boost v1.88+, the v2 process API is default
0020 MpSolverStatus runChildProcessBoost(const std::string& program,
0021                                     const std::vector<std::string>& args,
0022                                     const std::filesystem::path& runDir,
0023                                     const WrappedFileHandle& outputHandle,
0024                                     const Acts::Logger& logger) {
0025   using namespace boost::process;
0026 
0027   // find the pede installation
0028   auto thePede = environment::find_executable(program);
0029   if (thePede.empty()) {
0030     ACTS_ERROR("Failed to find the solver program '" << program << "'");
0031     return MpSolverStatus::ProgNotFound;
0032   }
0033 
0034   boost::asio::io_context io;
0035 
0036   process_stdio stdio{};
0037   if (outputHandle.isRedirected()) {
0038     stdio = process_stdio{{}, outputHandle(), outputHandle()};
0039   }
0040   // now run the fit
0041   process theProcess(io, thePede, args, process_start_dir(runDir.string()),
0042                      stdio);
0043   theProcess.wait();
0044   if (theProcess.exit_code() != 0) {
0045     ACTS_ERROR("Failed to run the solver process!");
0046     return detail::MpSolverStatus::FailedRun;
0047   }
0048   return detail::MpSolverStatus::OK;
0049 }
0050 
0051 }  // namespace ActsPlugins::detail