I am using boost process in async mode to run shell commands from a C++ application. The following code works well in Linux (CentOS 7 in my case), but fails on Solaris 10. On Solaris 10, the return code is 127 and stdout and stderr are empty.
#include <iostream>
#include <thread>
#include <boost/process.hpp>
#include <boost/asio.hpp>
namespace bp = boost::process ;
int main(int argc, char** argv)
{
std::future<std::string> dataOut;
std::future<std::string> dataErr;
std::string command = "ls";
boost::asio::io_service ios;
bp::child c(command, bp::std_out > dataOut, bp::std_err > dataErr, ios);
ios.run();
c.wait();
int result = c.exit_code();
std::string stdOut = dataOut.get();
std::string stdErr = dataErr.get();
std::cout << "Exit Code " << result << std::endl;
std::cout << "stdOut " << stdOut << std::endl;
std::cout << "stdErr " << stdErr << std::endl;
return 0;
}
Output on CentOS 7
Exit Code 0
stdOut a.out
main.cpp
Process.cpp
Process.h
simple.cpp
stdErr
Output on Solaris 10
Exit Code 127
stdOut
stdErr
Please help me figure what is going on.
Aucun commentaire:
Enregistrer un commentaire