[v2][Windows] Cannot redirect stdout to a file
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- cpp
- Domain
- operating-systems
Research direction
Start by reproducing the provided execProc example on Windows with Boost 1.86, comparing process_stdio output to the basic_stream_file target and to a readable_pipe. Trace the process v2 stdout-redirection entry point used by process_stdio; done means the created output file contains the child process's stdout after the process exits.
Written by the indexing model from the issue text.
Description
I am using boost process v2 from the 1.86 version of the boost library.
The following code is intended to redirect stdout to a file. It creates the file but the contents of stdout are not written to it; the file size is zero. When I redirect stdout to a pipe, the pipe contains the expected result.
I guessed at how to write the code to redirect stdout to a file, as I could not find any example in the documentation or online. So I have probably not done it right.
#include <boost/process/v2.hpp>
#include <boost/asio/read.hpp>
#include <boost/asio/readable_pipe.hpp>
#include <boost/asio/basic_stream_file.hpp>
namespace proc = boost::process::v2;
namespace asio = boost::asio;
std::tuple<int, std::string> execProc(const std::string& exePath, const std::vector<std::string>& args,
const std::string& outputFilePath)
{
asio::io_context ctx;
asio::basic_stream_file<asio::any_io_executor> outStream(ctx, outputFilePath.c_str(),
asio::file_base::write_only | asio::file_base::create | asio::file_base::exclusive);
asio::readable_pipe errPipe{ctx};
proc::process proc{ ctx, exePath, args, proc::process_stdio{{}, outStream, errPipe}};
std::string error;
boost::system::error_code ec;
auto errLen = asio::read(errPipe, asio::dynamic_buffer(error), ec);
auto exitCode = proc.wait();
outStream.close();
return std::make_tuple(exitCode, std::move(error));
}
- Dominant language
- C++
- Stars
- 145
- Forks
- 151
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from boostorg/process
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
All issues in boostorg/process
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
objectionary/eo-graphs#74 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
enhancement
Difficulty 1/5 Under an hour Newbie friendliness 88/100
QuantStack/git2cpp#187 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100