小编Ham*_*JML的帖子

在C++中从外部程序中捕获stderr和stdout

我正在尝试编写一个运行外部程序的程序.

我知道我可以抓住stdout,我可以一起抓住stdout,stderr但问题是我可以抓住stderrstdout分开吗?

我的意思是,例如,stderr变量STDERRstdout变量STDOUT.我的意思是我希望他们分开.

另外,我需要在变量中输出外部程序的退出代码.

c++ linux

5
推荐指数
1
解决办法
1733
查看次数

检查线程是否在c ++ 11中完成?

我需要一种方法来了解我正在运行的线程是否已完成.如果没有完成,则等待,如果完成则打印成功的消息.

我没有从库线程中找到c ++ 11中的方法或类似的东西.我无法设置全局变量,因为我使用的内部线程execvp如果成功则不会返回.

有没有办法做到这一点?方法或旗帜或其他任何东西.

Edit: 为了清楚起见,我想编写一个检查线程是否完成的函数.

c++ multithreading c++11

1
推荐指数
1
解决办法
5314
查看次数

How much data is in pipe(c++)

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.

c++ pipe

0
推荐指数
1
解决办法
307
查看次数

标签 统计

c++ ×3

c++11 ×1

linux ×1

multithreading ×1

pipe ×1