- 论坛徽章:
- 0
|
我有个程序, 启动起来按照一定顺序调用多个可执行程序, 并且其他程序是一直运行的...
代码如下:
for(its=pXmlElement->begin(); its!=pXmlElement->end(); its++)
{
judo::Element *pEle = (judo::Element*)*its;
if(pEle->getType() != judo::Node::ntElement)
{
continue;
}
string sExeName = pEle->getCDATA();
pid_t pid;
if((pid = fork()) < 0)
{
ErrorMsg("%s", "fork error");
}
else if(pid == 0)
{
printf("begin sExeName = %s\n", sExeName.c_str());
if(execl(sExeName.c_str(), sExeName.c_str(), NULL) < 0)
{
ErrorMsg("%s", "execle error");
}
printf("end sExeName = %s\n", sExeName.c_str());
}
if(waitpid(pid, NULL, 0) < 0)
{
ErrorMsg("%s", "wait error");
}
sleep(1);
}
现象, 启动一个程序后, 这个进程不退出, 下一个进程就启动不起来.... |
|