C++(boost):通过boost::process::child同步调用其他程序

boost提供了boost::process::child,可以通过其调用其他程序,并获得输出:

#include 
#include 
#include 
#include 
#include 
#include 

using namespace std;

template 
tuple > execCmd(const char* path, ArgTypes&&... tArgs)
{
    vector stdOutput;
    boost::process::ipstream stdOutStream;
    boost::process::child execProg(path, const_cast(tArgs)...,
                                   boost::process::std_out > stdOutStream);
    string stdOutLine;

    while (stdOutStream && getline(stdOutStream, stdOutLine) && !stdOutLine.empty())
    {
        stdOutput.emplace_back(stdOutLine);
    }

    execProg.wait();

    int retCode = execProg.exit_code();
    return make_tuple(retCode, stdOutput);
}

int main()
{
    int cmdRetC

你可能感兴趣的:(C/C++,c++)