How to create two child process executing parallel

2019-08-15 11:07发布

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 ?

标签: c++ linux fork
2条回答
2楼-- · 2019-08-15 11:33

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

查看更多
男人必须洒脱
3楼-- · 2019-08-15 11:34

Spawn the new processes with fork();

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

查看更多
登录 后发表回答