boost提供了boost::process::child,可以通过其调用其他程序,并获得输出,通过以下方式还可以为执行设定一个timeout时长:
//exe_cmd.hpp
#pragma once
#include <boost/process/child.hpp>
#include <boost/process/io.hpp>
#include <vector>
#include <iostream>
#include <string>
#include <tuple>
#include <chrono>
#include <thread>
template <class T>
inline std::string toStr(T t)
{
return to_string(t);
}
template <>
inline std::string toStr(const std::string t)
{
return t;
}
template <>
inline std::string toStr(const char* t)
{
return std::string(t);
}
template <>
inline std::string toStr(char* t)
{
return std::string(t);
}
template <typename... ArgTypes>
std::tuple<int, std::