Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/163.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 当一个进程以`boost::process``结束时,你怎么能不等待呢?_C++_Windows_Boost_Process_Boost Process - Fatal编程技术网

C++ 当一个进程以`boost::process``结束时,你怎么能不等待呢?

C++ 当一个进程以`boost::process``结束时,你怎么能不等待呢?,c++,windows,boost,process,boost-process,C++,Windows,Boost,Process,Boost Process,我有主程序和系统windows计算器。我想从主程序运行计算器,然后等待用户关闭它,然后放弃对主程序的控制 我尝试以下解决方案: auto child = boost::process::child("calc.exe"); child.wait(); 及 在这两种情况下,计算器都会启动,但主进程不会等到子进程关闭后再运行 我该怎么做?您需要使用start/wait calc.exe技巧。如何从boost::process::child实现这一点只是一个练习。您似乎在以正确的

我有主程序和系统windows计算器。我想从主程序运行计算器,然后等待用户关闭它,然后放弃对主程序的控制

我尝试以下解决方案:

auto child = boost::process::child("calc.exe");
child.wait();

在这两种情况下,计算器都会启动,但主进程不会等到子进程关闭后再运行


我该怎么做?

您需要使用
start/wait calc.exe
技巧。如何从boost::process::child实现这一点只是一个练习。您似乎在以正确的方式等待。可能
calc.exe
只是一个真正的计算器的启动程序,当你在Windows 10上运行时,你的程序会在完成后继续运行。calc.exe不是计算器应用程序。它是一个在启动计算器后立即退出的发射器。
auto child = boost::process::child("calc.exe");
while (child.running()) {}