我正在尝试编写一个运行外部程序的程序.
我知道我可以抓住stdout,我可以一起抓住stdout,stderr但问题是我可以抓住stderr并stdout分开吗?
我的意思是,例如,stderr变量STDERR和stdout变量STDOUT.我的意思是我希望他们分开.
另外,我需要在变量中输出外部程序的退出代码.
我需要一种方法来了解我正在运行的线程是否已完成.如果没有完成,则等待,如果完成则打印成功的消息.
我没有从库线程中找到c ++ 11中的方法或类似的东西.我无法设置全局变量,因为我使用的内部线程execvp如果成功则不会返回.
有没有办法做到这一点?方法或旗帜或其他任何东西.
Edit: 为了清楚起见,我想编写一个检查线程是否完成的函数.
I am trying to guess how much data is in pipe, and I don't want to use while(read) because it is blocking until EOF.
Is there any way to do that?
I real I want something like this:
i = pipe1.size();
pipe1.read(i);
Run Code Online (Sandbox Code Playgroud)
I say again, I don't want to use while (read) because it is blocking until EOF.