Some systems have the vfork() system call, which was originally designed as a lower version of fork() . since fork() meant copying the entire address space of the process, and therefore was quite expensive, the vfork() function was (in version 3.0BSD).
However, since vfork() was introduced, the fork() implementation has improved significantly, especially with the introduction of "copy-on-write" , where copying the process address space is transparently tampered with, allowing both processes to access the same physical memory, while none of them will not change that. This pretty much eliminates the vfork(); excuse vfork(); Indeed, most systems now do not have the original vfork() functionality completely. However, for compatibility, there could still be a vfork() , which simply calls fork() without trying to emulate all the semantics of vfork() .
As a result, it is very unwise to actually use any of the differences between fork() and vfork() . In fact, it is probably unwise to use vfork() at all unless you know exactly why you want to.
The main difference between the two is that when a new process is created using vfork() parent process is temporarily suspended, and the child process can take up the parent address space. This strange state continues until the child process exits or calls execve() , after which the parent process continues.
This means that the vfork() child process must be careful to avoid unexpected changes to the variables of the parent process. In particular, the child process should not return from the function containing the vfork() call, and it should not call exit() (if it needs to exit, it should use _exit(); in fact, this is also true for the normal fork() child )
Rajesh pal
source share