aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/Utilities/StartProcess.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/common/Utilities/StartProcess.cpp b/src/common/Utilities/StartProcess.cpp
index 8d713540e11..3cdc5c095bc 100644
--- a/src/common/Utilities/StartProcess.cpp
+++ b/src/common/Utilities/StartProcess.cpp
@@ -84,17 +84,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<FILE> 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
};