+ -
当前位置:首页 → 问答吧 → 如何让子进程继承父进程的线程

如何让子进程继承父进程的线程

时间:2011-06-28

来源:互联网

linux环境下,调用fork创建一个进程,它仅包含调用该fork的线程。如何使fork创建的进程包含调用线程所在进程的所有线程副本呢?
求高手指点

作者: t_presley   发布时间: 2011-06-28

clone ??
没用过

作者: justkk   发布时间: 2011-06-28

不可能!
线程不是系统资源
fork是完全复制父进程,clone是部分复制。
看看linux内核情景分析,里面进程部分说得很明了

作者: wzzww   发布时间: 2011-06-28

apue 里面有一句话
fork之后,
Inside the child process, only one thread exists. It is made from a copy of the thread that called fork in the parent.

作者: justkk   发布时间: 2011-06-28