How to create two child process executing parallel from a single parent process in C++?

瘦欲@ 提交于 2019-12-24 07:53:57

问题


Hi I'm working gin C++ on Linux platform. I have a parent process. i need to create two child process from this parent which will be execute in parallel for some time. While Parent process is waiting for both the process to complete and then it finishes its execution.

any suggestion ?


回答1:


use fork() and exec family of functions to start child processes. parent process can call waitpid till child process exists.

exec link: http://linux.about.com/library/cmd/blcmdl3_execvp.htm




回答2:


Spawn the new processes with fork();

Then in the parent process you can use waitpid() to wait for both of them to finish.



来源:https://stackoverflow.com/questions/13561461/how-to-create-two-child-process-executing-parallel-from-a-single-parent-process

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!