+ -
当前位置:首页 → 问答吧 → 等待子进程退出的问题

等待子进程退出的问题

时间:2011-11-24

来源:互联网

CreateProcess创建子进程,WaitForSingleObject等待子进程退出,都没问题

现在情况是子进程可能又启动了其他进程,我需要等所有子进程退出后WaitForSingleObject才返回,该怎么处理?

作者: aqtata   发布时间: 2011-11-24

遍历进程快照?

作者: funxu   发布时间: 2011-11-25

让子进程也WaitForSingleObject等待它的子进程退出

作者: lhylhy   发布时间: 2011-11-25

道理一样吧,子进程也要用WaitForSingleObject等待子子进程初始化结束

作者: kaikai_kk   发布时间: 2011-11-25

最标准的方法:使用作业(Job)对象。

http://msdn.microsoft.com/en-us/library/windows/desktop/ms684161(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/ms684847(v=vs.85).aspx#job_object_functions

Windows系统中使用“作业”来管理一组相关进程。A job object allows groups of processes to be managed as a unit. Job objects are namable, securable, shareable objects that control attributes of the processes associated with them. Operations performed on a job object affect all processes associated with the job object. Examples include enforcing limits such as working set size and process priority or terminating all processes associated with a job.

作者: JPEXE   发布时间: 2011-11-25