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 
0013 namespace ActsPlugins::detail {
0014 
0015 MpSolverStatus runChildProcessBoost(const std::string& program,
0016                                     const std::vector<std::string>& args,
0017                                     const std::filesystem::path& runDir,
0018                                     const WrappedFileHandle& outputHandle,
0019                                     const Acts::Logger& logger) {
0020   namespace bp = boost::process;
0021 
0022   // find the pede installation
0023   auto thePede = bp::search_path(program);
0024   if (thePede.empty()) {
0025     ACTS_ERROR("Failed to find the solver program '" << program << "'");
0026     return MpSolverStatus::ProgNotFound;
0027   }
0028 
0029   bp::child theProcess;
0030   if (outputHandle.isRedirected()) {
0031     theProcess = bp::child(thePede, args, bp::start_dir = runDir.string(),
0032                            (bp::std_out & bp::std_err) > outputHandle());
0033   } else {
0034     theProcess = bp::child(thePede, args, bp::start_dir = runDir.string());
0035   }
0036 
0037   theProcess.wait();
0038   if (theProcess.exit_code() != 0) {
0039     return MpSolverStatus::FailedRun;
0040     ACTS_ERROR("Failed to run the solver process!");
0041   }
0042   return MpSolverStatus::OK;
0043 }
0044 
0045 }  // namespace ActsPlugins::detail