如何创建两个子进程从C ++中的单个父进程并行执行? [英] How to create two child process executing parallel from a single parent process in C++?

查看:438
本文介绍了如何创建两个子进程从C ++中的单个父进程并行执行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我在Linux平台上工作gin C ++。
我有一个父进程。我需要创建两个子进程从这个父,将并行执行一段时间。

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.

任何建议?

推荐答案

使用 fork() exec
父进程可以调用 waitpid ,直到子进程存在。

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

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

这篇关于如何创建两个子进程从C ++中的单个父进程并行执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆