boost::process : write both stdout and stderr to the same stream ?
Hi, Is it possible to write both the stdout and stderr stream to the same output file/stream ? I am hoping to emulate ``` bp_stdout_stderr_app > output.txt 2>&1 ``` I tried doing something like that but get a runtime error Run output ``` terminate called after throwing an instance of 'boost::process::process_error' what(): dup3() failed: Bad file descriptor stdout : 000 stdout : 020 stdout : 040 Aborted (core dumped) ``` Source code ``` #include <boost/process.hpp> #include <iostream> using namespace boost::process; int main() { ipstream pipe_stream; child c("bp_stdout_stderr_app", std_out > pipe_stream, std_err > pipe_stream); std::string line; while (pipe_stream && std::getline(pipe_stream, line) && !line.empty()) std::cerr << line << std::endl; c.wait(); } ``` Cheers -- Nicholas Yue https://www.linkedin.com/in/nicholasyue/
participants (1)
-
Nicholas Yue