Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Early BSD implementations were among those in which fork() performed a literal duplication of the parent’s data, heap, and stack. As noted earlier, this is wasteful, especially if the fork() is followed by an immediate exec(). For this reason, later versions of BSD introduced the vfork() system call, which was far more efficient than BSD’s fork(), although it operated with slightly different (in fact, somewhat strange) semantics. Modern UNIX implementations employing copy-on-write for implementing fork() are much more efficient than older fork() implementations, thus largely eliminating the need for vfork(). Nevertheless, Linux (like many other UNIX implementations) provides a vfork() system call with BSD semantics for programs that require the fastest possible fork. However, because the unusual semantics of vfork() can lead to some subtle program bugs, its use should normally be avoided, except in the rare cases where it provides worthwhile performance gains.
Like fork(), vfork() is used by the calling process to create a new child process. However, vfork() is expressly designed to be used in programs where the child performs an immediate exec() call.