是叉()和vfork()之间的区别? [英] what is the difference between fork() and vfork()?

查看:89
本文介绍了是叉()和vfork()之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是叉()和vfork()之间的区别?和vfork的不一样返回fork()的。

what is the difference between fork() and vfork()? and does vfork return like fork().

推荐答案

的vfork 的意图是消除复制的全过程图像的开销,如果你只是想做一个 EXEC * 中的孩子。因为 EXEC * 替换子进程的整体形象,也就是在复制父的形象没有任何意义。

The intent of vfork was to eliminate the overhead of copying the whole process image if you only want to do an exec* in the child. Because exec* replaces the whole image of the child process, there is no point in copying the image of the parent.

if ((pid = vfork()) == 0) {
  execl(..., NULL); /* after a successful execl the parent should be resumed */
  _exit(127); /* terminate the child in case execl fails */
}

对于其他类型的用途,的vfork 是危险的和未predictable。

For other kinds of uses, vfork is dangerous and unpredictable.

使用最新的内核,但是,包括Linux,的主要好处的vfork 已经由于的方式消失了实现的。而不是复制时,将执行的整体形象,写入时复制技术的使用。

With most current kernels, however, including Linux, the primary benefit of vfork has disappeared because of the way fork is implemented. Rather than copying the whole image when fork is executed, copy-on-write techniques are used.

这篇关于是叉()和vfork()之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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