Linux编程:execv在程序中同步调用其他程序_风静如云的博客-CSDN博客
介绍了同步的调用其他程序的方法。
有的时候我们需要异步的调用其他程序,也就是不用等待其他程序的执行结果,尤其是如果其他程序是作为守护进程运行的,也无法等待其运行的结果。
//ssss程序
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/wait.h>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
using namespace std;enum ExecRes{EXEC_OK = 0,EXEC_INVALID_PARAM,EXEC_PARENT_FORK_FAILED,EXEC_CHILD_FORK_FAILED,EXEC_MALLOC_FAILED,EXEC_FAILED
};int execCmdAsync(const string& cmdPath, const vector<string>& cmdArgv)
{int ret = EXEC_OK;if(cmdPath.length() == 0 || cmdArgv.size() == 0){//invalid inpu