【发布时间】:2014-02-28 02:54:35
【问题描述】:
考虑一下
#include <cstdio>
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <vector>
#include <string>
#include <iterator>
#include <cmath>
#include <thread>
#include <cerrno>
#include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <getopt.h>
#include <boost/algorithm/string.hpp>
#include "utils.cpp"
#include "pstream.h"
//pstream is the process stream library as below
void doThings()
{
while(not exitflag, a global){
if(some condition) {execl (a bash script); std:cout << "this text will never get printed, process ends at execl" <<endl;}
}}}
int main()
{//detach doThings as a thread here
}
我可以保证没有设置全局 exitflag,而且即使设置了标志,也会打印 std::cout 行,因为没有命令中断并跳转到 while 结束来庆祝打印消息之前的终止。
我做错了什么?顺便说一句:shell 脚本运行良好。
编辑:(感谢 minitech)我不想让原始程序死掉
线程:http://sourceforge.net/projects/pstreams/files/pstreams/Release%200.8.x/
【问题讨论】:
-
我不知道你在这里问什么。您能否展示一下您得到的输出以及您的期望?
标签: c++ multithreading exec