vfork() - spawn a new process efficiently, sharing virtual memory
#include <unistd.h>
pid_t vfork(void)
The vfork(2) call creates a new process, just as fork(2) does, but it doesn't fully copy the address space of the parent process. By sharing the space, process creation is much faster in a paged environment. Normally, vfork(2) is a faster way to create a new process before an exec-family call.
However, the greater speed has a greater risk to the parent process if the child process does not immediately exec(2) or _exit(2). (Leaving with exit(3) isn't recommened because exit(3) flushes and closes the I/O data structures of the parent.)
On success, vfork(2) call returns with 0 to the child process and it returns the process ID of the child process to the parent process. If the call fails, it returns -1 to the parent process, does not create a new process, and sets errno to indicate the error.
The vfork(2) call can fail for the following reasons:
exec(2)
exit(3)
fork(2)
wait(2)