From 9af6bf15aa2fe836c3ebba306eaaa8971f00fac4 Mon Sep 17 00:00:00 2001 From: Giacomo Pozzoni Date: Sat, 16 Jan 2021 21:30:57 +0100 Subject: CI/CircleCI: Expose binaries built on Circle CI as docker images in the Circle CI artifacts (#25832) Co-authored-by: Shauren --- src/common/Utilities/StartProcess.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/common/Utilities/StartProcess.cpp') diff --git a/src/common/Utilities/StartProcess.cpp b/src/common/Utilities/StartProcess.cpp index ab81f4db5df..5c8e0f79763 100644 --- a/src/common/Utilities/StartProcess.cpp +++ b/src/common/Utilities/StartProcess.cpp @@ -81,17 +81,24 @@ static int CreateChildProcess(T waiter, std::string const& executable, executable.c_str(), boost::algorithm::join(argsVector, " ").c_str()); } + // prepare file with only read permission (boost process opens with read_write) + std::shared_ptr inputFile(!input.empty() ? fopen(input.c_str(), "rb") : nullptr, [](FILE* ptr) + { + if (ptr != nullptr) + fclose(ptr); + }); + // Start the child process child c = [&]() { - if (!input.empty()) + if (inputFile) { // With binding stdin return child{ exe = boost::filesystem::absolute(executable).string(), args = argsVector, env = environment(boost::this_process::environment()), - std_in = input, + std_in = inputFile.get(), std_out = outStream, std_err = errStream }; -- cgit v1.2.3