问题描述
有一个启动一个进程,并等待它的子进程结束的方式?我的问题如下。我有一个setup.exe文件。如果我启动它,它运行4-5秒,并启动1或2新工艺,运行setup.exe关闭。
Is there a way to start a process, and wait for its child process to finish? My problem is the following. I have a setup.exe. If i start it, it runs for 4-5 secs and starts 1 or 2 new processes, and the setup.exe closes.
如果我的CreateProcess和WaitForSingleObject的开始SETUP.EXE,然后它会等待才把直到setup.exed关闭。
If i start setup.exe with createprocess and with WaitForSingleObject, then it will wait only then until the setup.exed closes.
有没有一种方法,要等到新工艺,由开始的setup.exe完呢?
Is there a way, to wait until the new processes, started by setup.exe finishes too?
感谢
推荐答案
莫比,您可以创建在启动一个互斥体并锁定。然后,使基地过程中使用WaitForSingleObject的API等待。当它的主人进程终止互斥自动销毁。
Maby you can create a Mutex on startup and lock it. Then, make base process wait for it using WaitForSingleObject api. The Mutex is automatically destroyed when its owner process is terminated.
另外,您可以创建用于终止当过程结束后子进程一个tmp文件,您可以SETUP.EXE检查是否存在FRIM知道如果进程仍在运行。
Alternatively you can create a tmp File in the child process which you terminate when the process is finished, your setup.exe can check if the frim exists to know if the process is still running.
这篇关于如何启动一个进程并等待它的子进程结束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!