I am using Boost Process
in async mode to get the stdout
, stderr
and return code of a shell command. In the code snippet below, is the call c.wait()
required? According to Boost Process 1.68
documentation it is not required where as it is required according to that of boost process 1.65.1
.
std::string command = 'ls';
boost::asio::io_service ios;
std::future<std::string> dataOut;
std::future<std::string> dataErr;
bp::child c(command, bp::std_in.close(), bp::std_out > dataOut, bp::std_err > dataErr, ios);
ios.run();
c.wait();
stdOut = dataOut.get();
stdErr = dataErr.get();
returnStatus = c.exit_code();
Now, I am using Boost 1.68
and when I remove the call to c.wait()
, I get a returnStatus
of 127
instead of the expected 0
, which I get when I add the c.wait()
call. What difference does the call c.wait()
make?
Aucun commentaire:
Enregistrer un commentaire