Linux編程:execv在程序中同步調(diào)用其他程序_風(fēng)靜如云的博客-CSDN博客
介紹了同步的調(diào)用其他程序的方法。文章來源:http://www.zghlxwxcb.cn/news/detail-665755.html
有的時(shí)候我們需要異步的調(diào)用其他程序,也就是不用等待其他程序的執(zhí)行結(jié)果,尤其是如果其他程序是作為守護(hù)進(jìn)程運(yùn)行的,也無法等待其運(yùn)行的結(jié)果。?文章來源地址http://www.zghlxwxcb.cn/news/detail-665755.html
//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
到了這里,關(guān)于Linux編程:在程序中異步的調(diào)用其他程序的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!